salukigirl
New Member
- Messages
- 78
- Reaction score
- 0
- Points
- 0
Hi. Um, I'm using this script and I have my database table named users. But something isn't working... I don't really know how to explain it better...
But I keep getting this error...
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/star/public_html/create_account.php on line 12
User account has been created!
Does anyone see what might be wrong in the coding?
PHP:
<?php
include_once("sql_connect.php");
$username = $_POST['username'];
$email = $_POST['email'];
$password = $_POST['password'];
$confirm = $_POST['confirm'];
$website = $_POST['website'];
$users_query = mysql_query("SELECT * FROM user");
$num_user = mysql_num_rows( $user_query );
if ( $password == $confirm )
{
if ( $num_user > 0 )
{
$user_query = mysql_query("SELECT * FROM user WHERE email='".$email."'");
$num_user_email = mysql_num_rows( $user_query );
if ( $num_user_email == 0 )
{
$user_query = mysql_query("SELECT * FROM user WHERE username='".$username."'");
$num_user_username = mysql_num_rows( $user_query );
if ( $num_user_username == 0 )
{
$user_query = mysql_query("INSERT INTO user VALUES( NULL, '".$username."', '".$email."', '".$password."', '".$website."')");
echo 'User account has been created!';
}
else
{
echo 'Username is already taken!';
}
}
else
{
echo 'Email address is already in use by another user';
}
}
else
{
$user_query = mysql_query("INSERT INTO user VALUES( NULL, '".$username."', '".$email."', '".$password."', '".$website."')");
echo 'User account has been created!';
}
}
else
{
echo 'Passwords do not match';
}
?>
But I keep getting this error...
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/star/public_html/create_account.php on line 12
User account has been created!
Does anyone see what might be wrong in the coding?