Jump to content

Archived

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

lamajlooc

Some help identifying the bad syntax please.

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?

Share this post


Link to post
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.

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

×

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.