unable to jump

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
m2babaey
Forum Contributor
Posts: 364
Joined: Sun May 20, 2007 9:26 am

unable to jump

Post by m2babaey »

Hi
in a signup form, the code below sends this error:
Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 14 in g:\programs new\easyphp\www\site\signup.php on line 43

Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 15 in g:\programs new\easyphp\www\site\signup.php on line 45
code:

Code: Select all

$result=mysql_query("SELECT * FROM publisher WHERE email='$email'" );
if (mysql_result($result,0,0)>0) error ('The email address you have provided already exists');
$result=mysql_query("SELECT * FROM publisher WHERE username='$username'" );
if (mysql_result($result,0,0)>0) error ('The username already exists');
thanks
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Any particular reason your using mysql_result() instead of mysql_num_rows()

You should also be escaping your data with mysql_real_escape_string() to avoid the possibility of SQL injection.
User avatar
webgroundz
Forum Commoner
Posts: 58
Joined: Thu Jun 21, 2007 1:20 am
Location: Philippines

Post by webgroundz »

why did you use

Code: Select all

mysql_result()
?
is that for checking that the email address is exist?.
if that so, i think this would be better :

Code: Select all

$result=mysql_query("SELECT * FROM publisher WHERE email='$email'" );
$count_row = mysql_num_rows($result);
if($count_row > 0)
{
    echo ("The email address you have provided already exists"); 
}
else
{
   //statement
}
http://www.php.net/manual/en/function.mysql-result.php

:) :) :)
User avatar
Gente
Forum Contributor
Posts: 252
Joined: Wed Jun 13, 2007 9:43 am
Location: Ukraine, Kharkov
Contact:

Post by Gente »

Code: Select all

SELECT COUNT(*) FROM publisher WHERE email='$email'
Post Reply