crazylegseddie Posted August 20, 2006 Share Posted August 20, 2006 I have a search script that I have inputted at the home of my site and works correctly but with the following script:[code] $sql = "SELECT pd_id, pd_name, pd_more, pd_more2, MATCH(pd_name, pd_more, pd_more2) AGAINST ('$searchstring' IN BOOLEAN MODE) FROM tbl_product WHERE MATCH(pd_name, pd_more, pd_more2) AGAINST ('$searchstring' IN BOOLEAN MODE) ORDER BY pd_name DESC"; } $result = mysql_query($sql) or die (mysql_error()); while($row = mysql_fetch_assoc($result)) { echo "<a href='categories.php?c=0&p=". $row['pd_id']. "'>".stripslashes(htmlspecialchars($row['pd_name'])).'</a><br />'; } [/code]A message saying 'query is empy' is displayed and cancels the rest of my html page. But if i remove 'or die (mysql_error());' then i get the following warning.'Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result' but the rest of the page now loads correctly. How do i overcome this problem im having?Any help will be cool. Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 20, 2006 Share Posted August 20, 2006 add this just after the query (without die();)echo mysql_error(); Quote Link to comment Share on other sites More sharing options...
crazylegseddie Posted August 20, 2006 Author Share Posted August 20, 2006 thx for reply but i inserted the following like this:[code] $result = mysql_query($sql); echo mysql_error();[/code]and recieved both unwanted comments:'Query was emptyWarning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result' Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted August 20, 2006 Share Posted August 20, 2006 It most likely means that your mysql connection is failing. Add the "or die(mysql_error());" to the end of your mysql_connect and any other db functions above the code you provided. Quote Link to comment Share on other sites More sharing options...
crazylegseddie Posted August 20, 2006 Author Share Posted August 20, 2006 it is definately not the connection as I have the connection stored in a config file and is functional over the rest of my site. If I add 'die(mysql_error());' then I just receive 'Query was empty' and the rest of the page after the php script does not load. :( Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted August 20, 2006 Share Posted August 20, 2006 Echo out your query and put it into phpMyAdmin or MySQL Query Browser and make sure that it is not a syntax error. Quote Link to comment Share on other sites More sharing options...
crazylegseddie Posted August 20, 2006 Author Share Posted August 20, 2006 it was a bit of unused script that was causing the problem. I removed it and now everything runs fine :) Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 20, 2006 Share Posted August 20, 2006 the query is empty, normally means there is no query$query = "SELECT * FROM table";$result = mysql_query($query2);//Note the 2 after the mysql_queryThis will respond with the query is empty, as $query2 does not exsists Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.