Jump to content

Some help identifying the bad syntax please.


lamajlooc

Recommended Posts

First, I'd like to say thanks to all those who responded to my other two questions.  Here's one that's bizarre though.

I'm getting an error on the following code:
$result = @mysql_query ($query);
        $row = mysql_fetch_array ($result, MYSQL_NUM);
        if ($row) {
            $_SESSION['date_last_in'] = $row[0];
        }

The error is "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource"

The wierd things are: a) according to php.net the syntax is CORRECT (unless I'm syslexic) and I've used this same code before with no troubles.

Any ideas?
Link to comment
Share on other sites

[code]
$result = @mysql_query ($query);
if($result)
{
        $row = mysql_fetch_array ($result, MYSQL_NUM);
        if ($row)
        {
            $_SESSION['date_last_in'] = $row[0];
        }
}

else
{
      //query didn't work, therefore $result is not a "valid MySQL result resource"
}
[/code]

Basically you need to make sure you're connected with your database properly and that your query is valid.
Link to comment
Share on other sites

you might also want to remove the '@' (at sign) in front of 'mysql_query' during testing, so that you see any and all errors that might be suppressed.
Docs on Error Control Operators:[url=http://|http://ca3.php.net/manual/en/language.operators.errorcontrol.php]|http://ca3.php.net/manual/en/language.operators.errorcontrol.php[/url]
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.