Jump to content

INSERT INTO.. not working


unistake

Recommended Posts

Hi all could you take a look at this.

 

I think I have gone wrong somewhere in the syntax as I can not find the problem in a spelling error etc. I could do with using someone elses eyes on this one!

 

It is coming up with the result "Couldn't execute query" - I have tested all the $_POST[values] that have echoed fine.

 

Thanks for the help.

 

$cxn = mysqli_connect($host, $user, $passwd,$dbname) 
or die ("Unable to connect!");

$sql = "SELECT email FROM Members WHERE email='$_POST[email]'";
$result = mysqli_query($cxn,$sql)
or die ("Couldn't execute query");

$num = mysqli_num_rows($result);
if ($num >0) // Login Name found 
{
	echo "The email address '$_POST[email]' is already registered!";
}
else // Login Name not found
{
	$today = date("Y-m-d h:i:s");
	$query = "INSERT INTO Members (id,name,email,telephone,password,icao,joined)
			VALUES ('','$_POST[name]','$_POST[email]','$_POST[telephone]','$_POST[password]','$_POST[code],'$today')";
	$result1 = mysqli_query($cxn,$query)
		or die ("Can't execute insert query");

	echo "You have successfully registered!";
}

Link to comment
https://forums.phpfreaks.com/topic/207611-insert-into-not-working/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.