skmit87 Posted October 25, 2010 Share Posted October 25, 2010 Hi All, i am facing the following issue in my code below: $dbQuery = "SELECT * from product where Title=\"$blobId\""; $query_result=mysql_query($dbQuery) or die (mysql_error()); echo $query_result; //I see that a "resource Id 2 is coming up $result = mysql_fetch_array($query_result) or die('no such data') ; //Its always saying no such data though the above query works fine in MYSQL command prompt. If you see the Mysql_fetch_arraly always goes into the die mode. It is to be noted that the above query works in Mysql command prompt. Also the $query_result has value as resource id #2. What seems to be the problem here kindly guide me... Quote Link to comment https://forums.phpfreaks.com/topic/216808-mysql-and-php-code-has-problems-in-mysql_fetch_array-pls-help-urgent/ Share on other sites More sharing options...
fenway Posted October 30, 2010 Share Posted October 30, 2010 That's hard to believe --mysql_fetch_assoc() should work just fine here. Quote Link to comment https://forums.phpfreaks.com/topic/216808-mysql-and-php-code-has-problems-in-mysql_fetch_array-pls-help-urgent/#findComment-1128489 Share on other sites More sharing options...
DavidAM Posted October 30, 2010 Share Posted October 30, 2010 Since you are getting a resource from mysql_query(), the query is execting successfully -- there are no syntax errors. Since mysql_fetch_array() is returning false on the first call, the query returned zero rows. Are you sure that $blobId contains what you think it does? Try echoing out $dbQuery before you execute it. Then copy and paste into your mySql command prompt. It could be that $blobId has trailing spaces or newlines or something else that you did not type at the command prompt. You might try using trim() on the $blobId before putting it in the query. Quote Link to comment https://forums.phpfreaks.com/topic/216808-mysql-and-php-code-has-problems-in-mysql_fetch_array-pls-help-urgent/#findComment-1128505 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.