I'm running MYSQL and PHP through XAMPP to make a CMS -- learning a lot but I'm super confused by this error.
The information was not accepted
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '1, visible = 1 WHERE id = 1' at line 3
So when I update the menu item through PHPMyAdmin it shows this
UPDATE `information` SET `menu` = 'Changed Menu Name' WHERE `information`.`id` = 1;
My relevant PHP would be, or view the entire file on my Gist:
if (empty($errors)){
$id = mysql_prep($_GET['info']);
$menu = mysql_prep($_POST['menu']); //use POST array for form method
$position = mysql_prep($_POST['position']);
$visible = mysql_prep($_POST['visible']);
$query = "UPDATE information SET
menu = '{$menu}',
position = {$position},
visible = {$visible}
WHERE id = {$id}";
$result = mysql_query($query, $connection);
if (mysql_affected_rows() == 1 ) {
//Successful
$message = "The information was correctly updated";
} else {
//Failure
$message = "The information was not accepted";
$message .= "<br>" . mysql_error();
}
} else {
//Errors are happening
$message = "There were " . count($errors) . " too many errors in the form";
}
}
I've tried adding my $connection variable in with my if (mysql_affected_rows() == 1 ) and updating the MySQL code to include spaces. I've also tried adding th $id variable in after WHERE
I'm pretty confused about how I'm to resolve this error. For more context, the repo for the project can be found here.
Really getting close to having a dynamic menu -- any help would be great!