Hello everyone :) I have this lines of codes and i get :
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in D:\xampp22\htdocs\folder\index.php on line 52 ( 19 in the code below )
<form method="POST" action="index.php">
CODE : <input type="text" placeholder="Type the code" name="searchfor" />
<input type="submit" name="submit" value="Search for the code">
</form>
<?php
if(isset($_REQUEST['submit'])){
$searchfor = $_REQUEST['searchfor'];
$terms = explode(",", $searchfor); // i've deleted this and no-positive results , i was thinking that it gives a false value to the code :-??
$query = "SELECT * FROM edit WHERE id=$searchfor" ; // i've tried also with WHERE id LIKE $searchfor
include ("link_to_connection_to_sql.php"); // it work's , it's tested
$query = mysql_query($query);
$num = mysql_num_rows($query); // here is the error
if($num > 0 && $searchfor != ''){
while ( $row = mysql_fetch_assoc($query)){
$price = $row['price'];
echo "$price";
}}else{
echo 'No results';
}
}
else{
echo 'Please fill the search form ';
}
?>
I will be gratefull if you help me with an explanation and a solution :) Thank you ! (I don't really understand the error , I'm at the begin )
- : If it helps , the table is edit with 2 columns id , price .. this should be a search by id and give the price of the id :D