At first I was getting this error
"Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in"
but then I added the code
if (!$result) {
die("Error<br />Query is: $sql<br />Error is: ".mysql_error());
}
I now I get the new error
"Error
Query is:
Error is: Query was empty"
I'm sure this is somthing simple I just can't figure it out 🙁
Here is my code
<?php
$k = $_GET['k'];
$terms = explode (" ", $k);
$query = "SELECT * FROM a7526299_product WHERE ";
foreach ($terms as $each) {
$i++;
if ($i == 1)
$query .="keywords LIKE '%each%' ";
else
$query .="OR keywords LIKE '%each%' ";
}
// connect
mysql_connect ("-------", "-------", "------");
mysql_select_db("a7526299_product");
$query = mysql_query ($query);
$result = mysql_query($sql);
if (!$result) {
die("Error<br />Query is: $sql<br />Error is: ".mysql_error());
}
$numrows = mysql_num_rows($query);
if ($numbers > 0) {
while ($row = mysql_fetch_assoc($query))
{
$id= $row['id'];
$id= $row['Brand'];
$id= $row['Description'];
$id= $row['Category'];
$id= $row['Price'];
$id= $row['Image'];
echo "$id, $Brand $Description, $Category, $Price, $Image";
}
}
else
echo "No results found for $k";
// disconnect
mysql_close();
?>