For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > July 2007 > Re: [PHP-DB] Newbie alert: supplied argument is not a valid MySQL result resource









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] Newbie alert: supplied argument is not a valid MySQL result resource
Niel Archer

2007-07-10, 3:58 am

Hi

On my way to bed so too tired too look closely, but at a guess I'd say
it's a logic error. I would guess this:

> $sid = mysql_fetch_array($query) || die ('Could not fetch from database:
> ' . mysql_error()); // <--- line 49


isn't evaluating in the order you expect.. You're using a logic
statement as an assignment, and the result of that get's assigned to your
variable not the resource you expect. Try it like this to see if it works:

$sid = mysql_fetch_array($query);
if ($sid === false) die ('Could not fetch from database: ' . mysql_error());

If that's not the problem, I haven't got a clue until after sleep and
coffee.

Niel
Niel

2007-07-11, 7:58 am

Hi

> On my way to bed so too tired too look closely, but at a guess I'd say
> it's a logic error. I would guess this:
>
>
> isn't evaluating in the order you expect.. You're using a logic
> statement as an assignment, and the result of that get's assigned to your
> variable not the resource you expect. Try it like this to see if it works:
>
> $sid = mysql_fetch_array($query);
> if ($sid === false) die ('Could not fetch from database: ' . mysql_error());
>
> If that's not the problem, I haven't got a clue until after sleep and
> coffee.


I've had some sleep, and coffee, and I see I missed something silly.

I should of suggested this

// get sid and write cookies
$query = mysql_query("SELECT MAX(SID) FROM Sessions");
if ($query === false) die ('Could not query database: ' . mysql_error());
$sid = mysql_fetch_array($query)
if ($sid === false) die ('Could not fetch from database: ' . mysql_error());


--
Niel Archer
153

2007-07-15, 5:13 pm

Heather Locklear and Ashlee Simpson In The Countryside!
http://www.reyrewh.com/Player.php?q=148803
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com