Wednesday, 7 August 2013

mysqli update query syntax error

mysqli update query syntax error

I'm getting the following error message, something wrong with the syntax
of my code apparently but I'm not sure what it is. If I change the $data
to something simple like "pie" it will update. Seems to be an error with
the serialized string?
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 '' . DB_PFIX .
'settings SET setting_options = 'a:12:{s:13:"website_title"' at line 2
code:
<?php
if( !empty( $_POST['submit'] ) ) {
$data = serialize( array(
'website_title' => $_POST['website_title'],
'website_slogan' => $_POST['website_slogan'],
'website_theme' => $_POST['website_theme'],
'website_homepage' => $_POST['website_homepage'],
'website_description' => $_POST['website_description'],
'website_keywords' => $_POST['website_keywords'],
'website_language' => $_POST['website_language'],
'website_timezone' => $_POST['website_timezone'],
'website_date_format' => $_POST['website_date_format'],
'website_time_format' => $_POST['website_time_format'],
'website_url' => $option['website_url'],
'website_path' => $option['website_path']
));
$query = '
UPDATE
' . DB_PFIX . 'settings
SET
setting_options = "' . $data . '"
WHERE
setting_name = "' . $setting_name . '"
';
$result = mysqli_query( $db_connect, $query );
if ( mysqli_affected_rows( $db_connect ) == 1 ) {
echo "GOOD!";
} else {
echo mysqli_error( $db_connect );
}
}
?>

No comments:

Post a Comment