MYSQLI, Class not found?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 
Hey guys,
 
 I'm doing a tutorial from a book (PHP and MySQL Web Development) and  I'm 
having a problem... when I use the script they supply I get this  error:
 
 
Fatal error: Class 'mysqli' not found  in 
C:\apachefriends\xampp\htdocs\results.php on line 29 
 
here is the code:
 
 
=======================================================
<?php
 
// create short variable  names
$searchtype=$_POST['searchtype'];
$searchtype=$_POST['searchterm'];
 
$searchterm= trim($searchterm);
 
if (!$searchtype || !$searchterm)
{
echo 'You have not  entered search details. Please go back and try  again.';
exit;
}
 
if (!get_magic_quotes_gpc())
{
$searchtype=  addslashes($searchtype);
$searchterm=  addslashes($searchterm);
}
 
$db = new mysqli('localhost', 'root', 'root', 'bookorama');
 

//$db = mysql_connect('localhost', 'root', 'root');  // tried  this way, no 
luck
//mysql_select_db("bookorama", $db);
 
if(mysqli_connect_errno())
{
echo 'Error: Could not connect  to the Database. Please try again later.';
exit;
}
 
$query = "select * from books where ".$searchtype." like  
'%".$searchterm."%'";
$result = $db->query($query);
 
$num_results = $result->num_rows;
 
echo '<p>Number of books found:  '.$num_results.'</p>';
 
for ($i=0; $i <$num_results; $i++)
{
$row =  $result->fetch_assoc();
echo '<p><strong>'.($i+1).'.  Title: ';
echo  htmlspecialchars(stripslashes($row['title']));
echo  '</strong><br />Author: ';
echo  stripslashes($row['author']);
echo '<br />ISBN: ';
echo  stripslashes($row['isbn']);
echo '<br />Price: ';
echo  stripslashes($row['price']);
echo '</p>';
}
 
$result->free();
$db->close();
 
?>
 
</body>
</html>
 
===================================================
 
I updated PHP from 5.0.3 to 5.0.4 to see if it would help, no luck.
 
Now I'm just completely lost.
 
Thanks,
 
Clint


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux