Jump to content

Mysql and PHP code has problems in MYSQL_fetch_array() pls help urgent


skmit87

Recommended Posts

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...

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.