After many hours of trying to understand what is wrong with this simple query, is there anything that I’m missing? It posts correctly, and everything works fine (e.g. it updates the DB with the variables correctly) but displays the following error every time upon submission:
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 ‘1’ at line 1
$eventIDResult = ((int)$_POST["eventIDResult"]);
$eventNameResult = ($_POST["eventNameResult"]);
$eventTextResult = ($_POST["eventTextResult"]);
$eventDateResult = ($_POST["eventDateResult"]);
$eventAgendaResult = ($_POST["eventAgendaResult"]);
$sql = mysql_query("UPDATE events SET eventName='$eventNameResult', eventText='$eventTextResult', eventDate='$eventDateResult', eventAgenda='$eventAgendaResult' WHERE eventID='$eventIDResult'");
if (!mysql_query($sql, $con))
{
die('Error: ' . mysql_error());
}
else
{
header('Location: ../add-remove-event.php');
exit;
}
mysql_close($con);
You’re calling
mysql_queryon the result of the previousmysql_query, which probably returns the number of rows affected (in this case, 1):What you probably meant to do was just put the query in a string: