Suddenly GD updated their MySQL servers last night from version 4.1 to 5.5. Now, I just realized that the algorithm to UPDATE or INSERT new rows of data into the table isn't working anymore. This is what I have (I've been using this same algorithm since 2007 with no issues, maybe now is a little outdated):
if($error_msg == "")
{
$sql = "UPDATE ".$db_prefix."cars SET
stored='".$_POST['stored_year']."-".$_POST['stored_month']."-".$_POST['stored_day']."',
year='".add_slashes($_POST['year'])."',
model='".add_slashes($_POST['model'])."',
type='".add_slashes($_POST['type'])."',
typemodel='".add_slashes($_POST['typemodel'])."',
bodystyle='".add_slashes($_POST['bodystyle'])."',
engine='".add_slashes($_POST['engine'])."',
trans='".add_slashes($_POST['trans'])."',
drive='".add_slashes($_POST['drive'])."',
color='".add_slashes($_POST['color'])."',
condition='".add_slashes($_POST['condition'])."',
millage='".add_slashes($_POST['millage'])."',
vin='".add_slashes($_POST['vin'])."',
price='".add_slashes(strip_out($_POST['price']))."',
low='".add_slashes(strip_out($_POST['low']))."',
high='".add_slashes(strip_out($_POST['high']))."',
features='".$features_total."',
comments='".add_slashes($_POST['comments'])."',
mk_comment='".add_slashes($_POST['mk_comment'])."',
title_page='".add_slashes($_POST['title_page'])."',
certified='".add_slashes($_POST['certified'])."',
sold='".add_slashes($_POST['sold'])."',
sold_txt='".add_slashes($_POST['sold_txt'])."',
se_index='".add_slashes($_POST['se_index'])."',
one_owner='".add_slashes($_POST['one_owner'])."',
special= '".$special."'
WHERE id=".$_GET["id"];
if(@mysql_query($sql)) die(header("Location: index.php?status=update"));
else
$error_msg = "Record was not updated because of invalid data posted.";
}
I just get:
"Record was not updated because of invalid data posted."
It is not showing any other error. I was just reading this post where it says that as from MySQL 5.0, you should include the database name before the table name $sql = "INSERT INTO database
.table
(columnOne
, columnTwo
)... but not sure.
If you have an idea of why this UPDATE isn't working anymore, I would really appreciate any help.
Edit: Taken from OP's comment: (for those wondering on the usage of the add_slashes()
function).
add_slashes
is inserted from the local functions file.
function add_slashes($string) {
if (!get_magic_quotes_gpc())
return addslashes($string);
else
return $string;
}
Edit: I tried adding mysql_error() and I got:
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 'condition='good', millage='7087', vin='2BFKOPP25B5YR501', price' at line 12