TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   TalkPHP Developer Team (http://www.talkphp.com/talkphp-developer-team/)
-   -   Php signup error(please help) (http://www.talkphp.com/talkphp-developer-team/6185-php-signup-error-please-help.html)

Donima4u 04-12-2012 03:31 AM

Php signup error(please help)
 
Please really need help with this. i tried writing a script for a sign up page but anytime i try to sign up, it shows this error message mysql_num_rows(): supplied argument is not a valid MySQL result resource what do i do . Here is the code @ the line the error was referred to

$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string(sha1($_POST['password']));
$email = mysql_real_escape_string($_POST['email']);
$avatar = mysql_real_escape_string($_POST['avatar']);
$dn = mysql_num_rows(mysql_query('select id from users where username="'.$username.'"'));
if($dn==0)
{
$dn2 = mysql_num_rows(mysql_query('select id from users'));
$id = $dn2+1;
if(mysql_query('insert into users(id, username, password, email, avatar, signup_date) values ('.$id.', "'.$username.'", "'.$password.'", "'.$email.'", "'.$avatar.'", "'.time().'")'))
{
$form = false;
?>

thanks in advance

tony 04-12-2012 04:29 AM

You should save your results of a query in a variable, because of this explanation in the return section of the mysql_query function:

Quote:

For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error.
So, if your mysql_query is not successful it returns a FALSE and mysql_num_rows doesn't take that as an argument.

I think that might be the problem.

ww628815 11-09-2012 08:03 AM

http://www.truereligionoutletcanada.ca/ are more fitted versus the traditional jeans.True Religion Outlet days there are designer jeans to comprehend relaxed fitting.

True Religion Womens Jeans which manufactures designer jeans True Religion Jeans Replay And more branded designer jeansCanada True Religion Mens Jeans the moment are noticed in the marketplace.

The few original designer brands like Jordache, Calvin Klein, and Dittos can also be re-occurring in the market.


All times are GMT. The time now is 03:25 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0