I am trying to run a MySQL query from a PHP script like this:
$q = "
UPDATE
cf_ab_companies, inndata200
SET
cf_ab_companies.col_158 = inndata200.AFakt_10_Fast_renhold,
cf_ab_companies.col_159 = IF ( inndata200.Startdato = "01.01.3000 00:00" OR inndata200.Startdato = "01.01.2000 00:00", NULL, str_to_date(inndata200.Startdato, '%d.%m.%Y')),
cf_ab_companies.col_160 = IF ( inndata200.Sluttdato = "01.01.3000 00:00" OR inndata200.Sluttdato = "01.01.2000 00:00", NULL, str_to_date(inndata200.Sluttdato, '%d.%m.%Y'))
WHERE
cf_ab_companies.model_id = inndata200.ImportGOID;";
mysql_query($q, $db);
But it seems that the query is not stored properly in PHP. What is the simplest way to store queries like this in PHP?
Thanks for all help
"in your string (e.g. hereinndata200.Startdato = "01.01.3000 00:00"). So you need to at least escape them (write them as\") or use'instead.