salut tous le monde j'ai un probléme avec la fonction mysqli, la connexion marche avec mysqli_connect(.....) mais le probléme se pose mysqli_free_result et mysqli_num_rows voila les erreurs:
Warning: mysqli_affected_rows() expects parameter 1 to be mysqli, boolean given in
C:\WebPHP\site1\results.php on line
35Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in
C:\WebPHP\site1\results.php on line
48
et voila le code :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Search result</title>
</head>
<body>
<center><h1> Book-O-Rama search result</h1></center>
<?php
$searchtype=$_POST['searchtype'];
$searchterm=$_POST['searchterm'];
$searchterm=trim($searchterm);
if(!$searchterm||!$searchtype)
{
echo 'You have not enetered details, Please go back and try again.';
exit;
}
if(!get_magic_quotes_gpc())
{
$searchterm=addslashes($searchterm);
$searchtype=addslashes($searchtype);
}
@ $db=mysqli_connect('localhost','youma85','dragon','bookorama');
if(mysqli_connect_errno())
{
echo 'error: could not connect to database. Please try again later';
exit;
}
$result=mysqli_query($db,"select * from books where ".$searchtype."like %".$searchterm."%");
$num_result=mysqli_num_rows($result);
echo '<p> number of books found:'.$num_result.'</p>';
for($i=0;$i<$num_result;$i++)
{
$row=$result->fetch_assoc();
echo '<p><strong>'.($i+1).'.Title: '.htmlspecialchars(stripslaches($row['title']));
echo '</strong><br> Author:'.stripslaches($row['author']).'<br>ISBN: ';
echo stripslaches($row['isbn']).'<br> Price: '.stripslaches($row['price']).'</p';
}
mysqli_free_result($result);
mysqli_close($db);
?>
</body>
</html>
merci.