Hey all -
I did a bit of searching and read up on the "..not a valid MySQL result resource" error.. but I can't seem to fit any of the solutions to my code.
Can I please get some help?
Here is the error:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /nfs/c01/h11/mnt/12486/domains/xx/html/login/signup_backend.php on line 32
We didn't like that.
UPDATED error (after doing a mysql error call):
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''members'(username,password,email)VALUES('xx','xx' at line 1
update 2 - after i changed my input syntax to be correct.
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /nfs/c01/h11/mnt/12486/domains/xx/html/login/signup_backend.php on line 39
We didn't like that.
<?php
$host="x"; // Host name
$username="x_shortusr"; // Mysql username
$password="x"; // Mysql password
$db_name="x_shortlogin"; // Database name
$tbl_name="x"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$email=$_POST['email'];
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
// encrypt password
$encrypted_mypassword=md5($mypassword);
$sql="INSERT INTO $tbl_name(username,password,email)VALUES('$myusername','$encrypted_mypassword','$email')";
$result=mysql_query($sql);
#
if(!$result) {
#
echo mysql_error();
#
}
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:woot.php");
}
else {
echo "We didn't like that.";
}
?>
Thanks a ton.. I'm just not quite sure what to do.