Hello,
First time on the board, hope someone can shed some light on what I imagine must be something fairly simple that I'm missing.
I have a couple of test pages up, one which has a form in which you enter a search word. Submiting the form then passes the term to the search results page.
My problem is that no results are displayed. Now I've played around a bit and this is what I've found.
The searched variable, $search is passed to the search results page because I echo it on the search results page i.e.
$search=$HTTP_GET_VARS['searched'];
print "you searched for " . $search;
This works.
The problem is with the MySQL query;
mysql_select_db($database_green_zebra, $green_zebra);
$query_Recordset1 = "SELECT * FROM products WHERE products.type LIKE '%$search%' OR products.description LIKE '%$search%'";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $green_zebra) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
The SELECT statement seems not to work.
If I replace it with SELECT * FROM products then it all works but as soon as I give it the $search variable it breaks with no results.
I also have a "show all" page which displays everything in the DB i.e.
SELECT * FROM products and this page works also. Is most certainly seems to be something to do with the variable $search. BTW I have globals set to off for security.
Now it all works locally on my machine, I'm running PHP 4.3.0 and MySQL 3.23.51 and Apache 2.0.
Hope someone can help with this.
Regards
Robyn