I am currently in a condition not to find any errors in this line of code. I am trying to add several data to mysql database using PHP.
It gets "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 '', 'geo')' at line 5" Error message when I try to register someone. "geo" is the value of the radio group element.
<?php
if($_GET["regname"] && $_GET["regemail"] && $_GET["regpass1"]
&& $_GET["regpass2"]&& $_GET["regfamilyname"]
&& $_GET["reggivenname"] && $_GET["radioGroup"] )
{
if($_GET["regpass1"]==$_GET["regpass2"])
{
$servername="localhost";
$database="aaa";
$username="bbbb";
$password="cccc";
$conn= mysql_connect($servername,$username, $password)
or die(mysql_error());
mysql_select_db($database,$conn);
$sql="INSERT INTO users (username,password,familyname,
email, givenname, is_admin, created_time, category) values
('" . $_GET["regname"] . "', '" .$_GET["regpass"]. "', '"
.$_GET["regfamilyname"]. "','" .$_GET["regemail"]. "', '"
.$_GET["reggivenname"]. "', '0', NOW()', '"
.$_GET["radioGroup"]. "')";
$result=mysql_query($sql,$conn) or die(mysql_error());
print "<h1>You have registered sucessfully</h1>";
print "<a href='index.php'>Go to login page</a>";
}
else print "Passwords doesnt match.";
}
else print"Invalid data;";
?>