I'm only 12 years old so don't use too much fancy words! XD
Anyways i'm trying to code a PHP register and login system intergrated with Flash for an MMO Virtual World i'm working on. But I keep getting the error above. :mad:
I signed up for PHP Builder hoping you guys can help me fix it!
I get this error specifically;
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/u660040034/public_html/data/register.php on line 10
This is my register.php code:
<?php /** REGISTRATION SCRIPT **/
require_once('../include/dbconnect.php');//require DB Connection
$user = $_GET['user']; //Method 'GET' retrieves the variables from flash
$pass = $_GET['pass']; //retrieve the variables from flash
//Query the databse for the user and pass combo
$result = mysql_query("SELECT * FROM accounts WHERE user = '$user'");
//if the rows returned from the query are over 0 (the username already exists)
if(mysql_num_rows($result) > 0){
//send flash the error to be displayed.
$register = "&err=Registration failed."; //'err' is the variable in flash for storing errors/succes
echo($register);
} else {
//If the username does not already exist insert the data into the database
mysql_query("INSERT INTO accounts (id,user,pass) VALUES ('','$user','$pass')");
//send flash the success message so the user may login
$register = "&err=Registration successful.";
echo($register);
}
?>
Then in my login code i get the same error, on the same line. :queasy:
<?php /** LOGIN SCRIPT **/
require_once('../include/dbconnect.php'); //require DB Connection
$user = $_GET['user']; //Method 'GET' retrieves the variables from flash
$pass = $_GET['pass']; //retrieve the variables from flash
//Query the databse for the user and pass combo
$result=mysql_query("SELECT * FROM accounts WHERE user = '$user' AND pass = '$pass'");
//if the rows returned from the query are over 0 (the username already exists)
if(mysql_num_rows($result) == 0){
//send flash the error to be displayed.
$login = "&err=Login failed."; //'err' is the variable in flash for storing errors/succes
echo($login);
} else {
//If the username does not already exist insert the data into the database
$row = mysql_fetch_array($result);
$user=$row['user'];
$pass=$row['pass'];
//send flash the success message along with the user and pass
$login = "&user=" . $user . "&pass=" . $pass . "&err=Login Successful.";
echo($login);
}
?>
Help me PHP Builder!