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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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