Jump to content

Mysql_Fetch_array error


ThePhpReaper

Recommended Posts

well, i tried to fetch field from my database using the following code:

$result=mysql_query("SELECT * FROM Persons WHERE username='$myusername'" );
while($row = mysql_fetch_row($result))

 

now that gives me following error:

Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in..

 

Link to comment
Share on other sites

it's times like that that you will find error capture propper handy.

$result=mysql_query("SELECT * FROM Persons WHERE username='$myusername'" ) or die ('Query !FAILED! with following error  -- '.mysql_error();

Once you can see what the problem is, and I have a hunch what that is (but need more info to say more than it's an error in the query), you can then start to debug the issue, you can also post the error along with the code and we all have a better chance.  it's easier to help someone when they can post "check manual for syntax to use near 'WHERE username =' " than with a PHP error generated because the code failed to create the output.

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.