I’m not sure if this is a mySql or PHP issue… I’m getting really confused about the response of my script. The script suppose to search a table in the DB according to the user’s input.
function searchDatabase($art_group, $category, $with_rec, $country) {
$q = "SELECT * FROM users_details WHERE group = '$art_group'";
$result = mysql_query($q, $this->connection);
return $result;
} // end SEARCH function
The result in the browser is :
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\\Xampp\\htdocs\\MYSITE\\ajax\\ajaxupload.php on line 24
I’ve tried to pass all the other parameters ($category, $with_rec and $country) and the script is working with ALL of them! :injured:
That’s why I thought it might be a mySql issue… I simply CAN’T figure out what’s wrong with the script or the table…
Please HELP! THNX
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group = artist ORDER BY full_name ASC' at line 1
which is even more confusing, as that’s EXACTLY what I passed to the script - i.e. I want the script to list the users that have value ‘artist’ at the column ‘group’
I’ve tried
$q = "SELECT * FROM users_details WHERE group = ".$art_group." ORDER BY full_name ASC";
and then
$q = "SELECT * FROM users_details WHERE group = '$art_group' ORDER BY full_name ASC";
even
$q = "SELECT * FROM users_details WHERE group = '".$art_group."' ORDER BY full_name ASC";
GROUP is a reserved word for MySQL, if it’s not to late - change the column name.
If its too late then you will have to backtick it everytime you use it.
$q = "SELECT * FROM users_details WHERE `group` = ".$art_group." ORDER BY full_name ASC";
Thank you guys! I think I’ve had a similar issue with a reserved word before… I guess I will remember the ‘group’ one now! Is there a list with reserved words for MySql?