Posted by Chris_Isaac (Chris Isaac), 25 July 2003Hi sorry, I'm back, I keep getting the following error
mysql_fetch_array(): supplied argument is not a valid MySQL result resource
from the snipit of code below, I can't understand why, its working for the other searches.
I've also checked the values for $name and $town and they both contain the correct information.
I've also tried substituting the command for mysql_fetch_row, but the error came up again. Am I doing anything obviously wrong?
Posted by admin (Graham Ellis), 26 July 2003Nothing obvious, no.
Is it possible that you variables could contain " characters? (Solution - use addslashes or quotemeta function).
Is it possible that a field or table name is mis-spelt?
Is it possible that you failed to mysql_connect or mysql_select_db?
Have you done several mysql_connect-s in your program, and you're sending your query to the wrong connection?
If it's not quickly apparent which of the above is the problem, print out the values in $town and $county and run the equivalent of the mysql_query call manually in a mysql client - that will give you further evidence from which to analyse the problem.
By the way - you should always check your return code from mysql_query, and if it's false exit gracefully ("Database tables not available at present") rather than crash out at the next call. You might be planning to add that code once you have the thing working, but it can be helpful at quite an early stage if the thing keeps aborting / doing funny things in the way your code is doing.
Posted by Chris_Isaac (Chris Isaac), 26 July 2003I've fixed it, the problem was with my if statement! I needed to check for $name and $town!
PH: 01225 708225 • FAX: 01225 793803 • EMAIL: email@example.com • WEB: http://www.wellho.net • SKYPE: wellho