I got this error message once before and it turned out I had used “group” as a field in my database, which was protected. Its possible I chose another word that I should not have, although this error is new and I"m not sure what has changed.
I have created a form to submit to a database. When a user submits, they get an e-mail with a confirmation URL. When the access that URL they get to the page where the problem is. It is supposed to find their record in the database and move it to the “Live” table so that it becomes visible.
Here is the Error message I am getting:
Error - Query Error: 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 '[email protected]','yes')' at line 2
Here is the PHP code from the page itself. I am not sure what the problem could be though.
[code]if (mysql_select_db ($db, $cn))
{
$sql = "SELECT * FROM unpublished WHERE email = '$email'";
$result = mysql_query($sql,$cn);
//echo " <P>Error - Query Error1: " . mysql_error() . "xx<P>";
while($row = mysql_fetch_array($result))
{
//Get data
$id = $row[‘id’];
$sex = $row[“sex”];
$name = $row[“name”];
$partner = $row[“partner”];
$city = $row[“city”];
$state = $row[“state”];
$length = $row[“length”];
$children = $row[“children”];
$num_children = $row[“num_children”];
$adopted = $row[“adopted”];
$denied = $row[“denied”];
$child = $row[“d_child”];
$health = $row[“d_health”];
$death = $row[“d_death”];
$gov = $row[“d_gov”];
$employment = $row[“d_employment”];
$immigration = $row[“d_immigration”];
$other = $row[“d_other”];
$legal = $row[“legal”];
$legal_cost = $row[“legal_cost”];
$story = $row[“story”];
$email = $row[“email”];
$list = $row[“list”];
$created = $row[“created”];
$country = $row[“country”];
$sql = “INSERT INTO live(id,created,sex,name,partner,length,city,state,country,children,num_children,adopted,denied,d_child,d_death,d_health,d_gov,d_employment,d_immigration,d_other,legal,legal_cost,story,email,list)
VALUES (’$id’,’$created’,’$sex’,’$name’,’$partner’,’$length’,’$city’,’$state’,’$country’,’$children’,’$num_children’,’$adopted’,’$denied’,’$child’,’$health’,’$death’,’$gov’,’$employment’,’$immigration’,’$other’,’$legal’,’$legal_cost’,’$story’,’$email’,’$list’)”;
$insert = mysql_query($sql,$cn);
if ($insert == TRUE)
{
$sql2 = "DELETE FROM unpublished WHERE email = '$email'";
$delete = mysql_query($sql2,$cn);
if ($delete == TRUE)
{
print "<h2>Your story has been posted to our website</h2>Thank you for your support. Don't forget to <a href="/gay_marriage_site/tell_a_friend.php">tell your friends about us.</a>";
}
else
{
print "Database update could not be completed";
echo " <P>Error - Query Error: " . mysql_error();
}
}
else
{
print "There was a technical problem, your story could not be posted. Please e-mail the <a href="/gay_marriage_site/contact.php">Contact Us</a>.";
echo " <P>Error - Query Error: " . mysql_error();
}
}
}
else
{
print “Could not connect to database. Please Contact Us.”;
echo "
Error - Query Error: " . mysql_error();
} [/code]