Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error report...why?

Status
Not open for further replies.

wudz

Programmer
Mar 28, 2001
135
GB
Hi,
I have a problem with the script below. works great when an email match is present, but I get an error if no such email exists. Being a newbie to PHP can someone put me right to the extra code or syntax change required and simple explanation would be appreciated.
Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 34 in /home/ on line 89



line88.... $result = mysql_query("SELECT user_id from AUCTION_invitedbuyerslist WHERE list_name = '$intro_email'")or exit(mysql_error());
line89.... $intro_id = mysql_result($result,0);

Many thanks in anticipation

John
 
If $intro_email does not match any records in the db, then no rows are returned. So when you call:
Code:
$intro_id = mysql_result($result,0);

You are requesting the first row of the result and there is no first row. You need to check for rows first [mysql_num_rows()] before calling the code above.
 
Hi Itsim,

Cheers for that and the explaination, brought up on BASIC many years ago and miss goto's etc...hi

Would the syntax below be correct?

$result = mysql_query("SELECT user_id from AUCTION_invitedbuyerslist WHERE list_name = '$intro_email'")or exit(mysql_error());
$rows= mysql_num_rows()
if ($rows==0) {
exit;
}
else { $intro_id = mysql_result($result,0);

//further queries

Does the exit syntax take you out of this flow until next flow...plse excuse the terms..hi


Cheers

John

 
Exit will halt the php engine and simply exit the script all together.

If you are in a function, you can use 'return' to exit the function such as 'return false;'. If you were in a loop, or a switch statement, you could use 'break;', but if your simply in procedural code, you will need to set $intro_id to some default value, and then later when you use $intro_id, check the value (against the default value) and proceed accordingly...

Ahh the days of goto...:)
 
Thanks Itshim,

All working great now,still learning the syntax and very very slowly getting there, thank goodness the logic is simlar..

Thanks again and no doubt will be posting again in the near future..

John
 
np, that's what the boards are for. Once you get the syntax down, it all starts to fall into place.

Good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top