Jump to content


Photo

weird php/mysql[


  • Please log in to reply
5 replies to this topic

#1 birdie

birdie
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts
  • LocationBirmingham UK

Posted 11 June 2006 - 07:31 PM

$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);

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

any help please

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 11 June 2006 - 08:11 PM

Do we get clues about what it does or doesn't do, or should we guess?

Any errors? Is error_reporting on?
Legend has it that reading the manual never killed anyone.
My site

#3 birdie

birdie
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts
  • LocationBirmingham UK

Posted 11 June 2006 - 08:25 PM

[!--quoteo(post=382624:date=Jun 11 2006, 09:11 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Jun 11 2006, 09:11 PM) View Post[/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,

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


#4 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 11 June 2006 - 09:43 PM

Try displaying the error AND the query:
$query = mysql_query($sql) or die("Error: ". mysql_error(). " with query ". $sql);

That might point you in the right direction.
Legend has it that reading the manual never killed anyone.
My site

#5 WendyLady

WendyLady
  • Members
  • PipPipPip
  • Advanced Member
  • 38 posts

Posted 11 June 2006 - 10:17 PM

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

#6 birdie

birdie
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts
  • LocationBirmingham UK

Posted 11 June 2006 - 10:35 PM

[!--quoteo(post=382665:date=Jun 11 2006, 11:17 PM:name=WendyLady)--][div class=\'quotetop\']QUOTE(WendyLady @ Jun 11 2006, 11:17 PM) View Post[/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\" /]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users