View Full Version : php error please help

03-30-2007, 08:43 AM
This is the code to fetch data from the database, but it's giving me an error.

$mysql = mysql_connect("localhost", "revoluti_darkquo", "bymyside", "revoluti_darkquote");
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
} else {
$sql = "SELECT * FROM data ORDER BY id desc LIMIT 5";
// $result = "SELECT * FROM data";
// $num_rows = mysql_num_rows($result);
$res = mysqli_query($mysqli, $sql);
if ($res) {
while ($newArray = mysqli_fetch_array($res, MYSQLI_ASSOC)) {
$id = $newArray['id'];
$quote = $newArray['quote'];
$email = $newArray['email'];
$name = $newArray['name']; ?>
<fieldset class="fieldset">
<legend>Quote #<?php echo "".$id."" ?></legend>
<table border="0" cellpadding="0" cellspacing="3" width="100%">
<div align="center"><?php echo"".$quote."" ?></div><br />
<div align="right"<b><i>By <a href="mailto:<?php echo "".$email."" ?>"><?php echo "".$name."" ?></a></i></b><br /></div>
<br />
// echo"".$quote." - <i>By ".$name."</i><br />Thought #".$id."<br/><br />";
} else {
printf("Could not retrieve records: %s\n", mysqli_error($mysqli));

And this is the error I'm getting!

Fatal error: Call to undefined function: mysqli_connect() in /home/revoluti/public_html/darkquote/index.php on line 81

can you please help?

03-30-2007, 05:06 PM
I don't know if it was your intention or not, but do you see you are using mysql_connect and assigning it to $mysql?

if seems like it should be

$mysqli = mysqli_connect("localhost", "...", "...", "...");
if (mysqli_connect_errno()) {


I don't understand why it would cause that error though, but it's something to look at.


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum