Page 1 of 1

unable to jump

Posted: Mon Jul 30, 2007 11:39 pm
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

Posted: Mon Jul 30, 2007 11:44 pm
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.

Posted: Mon Jul 30, 2007 11:46 pm
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

:) :) :)

Posted: Tue Jul 31, 2007 2:41 am
by Gente

Code: Select all

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