Hi, My site on one page is giving error like this. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/......./public_html/library/utility_functions.php on line 2828 Lines from that file on 2828 $sql_query="select category_name from ".TABLE_CATEGORY." where id='$catid' " ; $sql_ex=mysql_query($sql_query); $row =mysql_fetch_array($sql_ex);; return $row['category_name']; Please help... Rajiv
1. Can you echo query, and try to run it manually to check what it outputs? 2. It could be that query has error OR query returns NULL which is why this error comes. Try following code. $sql_query="select category_name from ".TABLE_CATEGORY." where id='$catid' " ; $sql_ex=mysql_query($sql_query); if($sql_ex && mysql_num_rows($sql_ex) > 0) { $row =mysql_fetch_array($sql_ex); return $row['category_name']; } PHP:
Hi got this error in phpmyadmin when I ran ... SQL query: $sql_query = "select category_name from ".TABLE_CATEGORY. " where id='$catid' "; MySQL said: #1064 - 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 '$sql_query="select category_name from ".TABLE_CATEGORY." where id='$catid' "' at line 1
Nah, that is wrong! Anyways, please try the code changes I have suggested first, if it does not work, we will get into query check.
If you look at the error it is outputting the full php code for the query. Not sure why, but it isn't parsing the code before executing it. TABLE_CATEGORY should be replaced with the table name and $catid should be some number and not a variable string.
$sql_query="select category_name from '".TABLE_CATEGORY."' where id=".$catid." " ; $sql_ex=mysql_query($sql_query); $row =mysql_fetch_array($sql_ex);; return $row['category_name']; Error is showin for line $row =mysql_fetch_array($sql_ex);; Above is the code used
I use this result is empty nothing in front end no error but no result $sql_query="select category_name from '".TABLE_CATEGORY."' where id=".$catid." " ; $sql_ex=mysql_query($sql_query); if($sql_ex && mysql_num_rows($sql_ex) > 0) { $row =mysql_fetch_array($sql_ex);; return $row['subcat_name']; } return '';