Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in registeruser.php on line 19
here's the code: while($row = mysql_fetch_array($result)) //line 19
<?php
//getting various parameters through user that has been entered in the previous page
//these parameters are encrypted in post request sent from previous page
$fname=$_POST['firstname'];
$lname=$_POST['lastname'];
$email=$_POST['email'];
$password=$_POST['password'];
$age=$_POST['age'];
$Country=$_POST['Country'];
//setting connection string
$con = mysql_connect("server","user","pass") or die ("Couldn't connect");
//flag variable to check if user already exits in the system
$flag=0;
//connecting to server
mysql_select_db("db", $con);
//checking if user already exits
$result = mysql_query("SELECT * FROM user where email='".$email."'");
//if there are any rows in result user exists
while($row = mysql_fetch_array($result)) //line 19
{
$flag=1;
}
//inserting new user into the system,if already exits won't be inserted as primay coloumn constriant is present
$result = mysql_query("INSERT INTO `db`.`user` (`email`, `password`, `f_name`, `l_name`, `age`, `Country`) VALUES ('".$email."','".$password."','".$fname."','".$lname."','".$age."','".$Country."')");
mysql_close($con);
//closing connection
if($flag==1)
{
//if user exists send him error or tell him he is registered or use other email address
header('Location: register.php?exist=1' );
}
else
{
header('Location: register.php?register=1' );
}
?>
I got this when I was transfering the whole system from localhost to a server.
Thanks guys 🙂