I have this query represented as a string (its shortened to make it easier to read):
$query = 'INSERT INTO mytable (ke_voucher_date) VALUES (\'%s\')';
Now this is what I do next:
$query = vsprintf($query, array_map('mysql_real_escape_string', $params));
mysql_query($query);
$params is an array holding all values that should be saved, in this case (because its shortened) only the date in the format dd.mm.yyyy (21.04.2012). The result is 21.04.2026 for example. Whats wrong with the code, ideas? Maybe the %s?
Thanks!
“21.04.2012” is not a format MySQL likes. You should always format your dates as
Y-m-d, e.g.2012-04-21.