Jump to content

Archived

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

birdie

weird php/mysql[

Recommended Posts

[code]
$ip = $_SERVER['REMOTE_ADDR'];
$sql = "SELECT * FROM portal_logintrys WHERE ip='$ip'";
$query = mysql_query($sql);
$numrows = mysql_num_rows($query);
$object = mysql_fetch_object($query);
[/code]

I have done this hundreds of times but this script just doesnt seem to worry. no idea why.

any help please

Share this post


Link to post
Share on other sites
Do we get clues about what it does or doesn't do, or should we guess?

Any errors? Is error_reporting on?

Share this post


Link to post
Share on other sites
[!--quoteo(post=382624:date=Jun 11 2006, 09:11 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Jun 11 2006, 09:11 PM) [snapback]382624[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Do we get clues about what it does or doesn't do, or should we guess?

Any errors? Is error_reporting on?
[/quote]

sorry,

[code]
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in
[/code]

Share this post


Link to post
Share on other sites
Try displaying the error AND the query:
[code]$query = mysql_query($sql) or die("Error: ". mysql_error(). " with query ". $sql);[/code]

That might point you in the right direction.

Share this post


Link to post
Share on other sites
The "not a valid resource" error has been driving me up the wall recently.

From what I can tell with my own code so far is that this really means, "I didn't manage to select/update/delete the thing you requested, and it's because you made an error in my code, silly". In other words, it didn't like your query somewhere.

For me it usually means that SQL wanted parentheses somewhere, or a single quote around something, etc. Sometimes what works in one place doesn't work somewhere else (I would say there are gremlins somewhere in my database, but I am sure it has more to do with my relatively NOOBIE status as a PHP programmer).

Wendy

Share this post


Link to post
Share on other sites
[!--quoteo(post=382665:date=Jun 11 2006, 11:17 PM:name=WendyLady)--][div class=\'quotetop\']QUOTE(WendyLady @ Jun 11 2006, 11:17 PM) [snapback]382665[/snapback][/div][div class=\'quotemain\'][!--quotec--]
The "not a valid resource" error has been driving me up the wall recently.

From what I can tell with my own code so far is that this really means, "I didn't manage to select/update/delete the thing you requested, and it's because you made an error in my code, silly". In other words, it didn't like your query somewhere.

For me it usually means that SQL wanted parentheses somewhere, or a single quote around something, etc. Sometimes what works in one place doesn't work somewhere else (I would say there are gremlins somewhere in my database, but I am sure it has more to do with my relatively NOOBIE status as a PHP programmer).

Wendy
[/quote]


ooh thanks u two, ive just found out it was some dodgey code which i did earlier which interupted it a little. thanks anyway [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]

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.