marcq
Member
Hi,
I'm trying to insert into / update the Acymailing (joomla extension) subscriber table some datas after data stored before calculations. But the following nasty message is displayed :
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 'IF EXISTS (SELECT name, email FROM gprh_acymailing_subscriber WHERE email = 'cli' at line 1 SQL=IF EXISTS (SELECT name, email FROM gprh_acymailing_subscriber WHERE email = 'client1-gprh-ce@webamazingapps.com') UPDATE gprh_acymailing_subscriber SET name = 'Membre 1 - CE', email = 'client1-gprh-ce@webamazingapps.com'; ELSE INSERT INTO gprh_acymailing_subscriber (name, email) VALUES ('Membre 1 - CE', 'client1-gprh-ce@webamazingapps.com')
I've checked the sql syntax (+ with a online syntax checker), but it seems that the code is ok.
So if someone could have a look at my code would be great :
Thanks a lot in advance, cheers,
Marc
I'm trying to insert into / update the Acymailing (joomla extension) subscriber table some datas after data stored before calculations. But the following nasty message is displayed :
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 'IF EXISTS (SELECT name, email FROM gprh_acymailing_subscriber WHERE email = 'cli' at line 1 SQL=IF EXISTS (SELECT name, email FROM gprh_acymailing_subscriber WHERE email = 'client1-gprh-ce@webamazingapps.com') UPDATE gprh_acymailing_subscriber SET name = 'Membre 1 - CE', email = 'client1-gprh-ce@webamazingapps.com'; ELSE INSERT INTO gprh_acymailing_subscriber (name, email) VALUES ('Membre 1 - CE', 'client1-gprh-ce@webamazingapps.com')
I've checked the sql syntax (+ with a online syntax checker), but it seems that the code is ok.
So if someone could have a look at my code would be great :
Code:
$query = $db->getQuery(true);
$query = "IF EXISTS (SELECT name, email FROM gprh_acymailing_subscriber WHERE email = '$ce_email_business')
UPDATE gprh_acymailing_subscriber
SET name = '$ce_nom', email = '$ce_email_business'
WHERE email = '$ce_email_business';
ELSE
INSERT INTO gprh_acymailing_subscriber (name, email) VALUES ('$ce_nom', '$ce_email_business')";
$db->setQuery($query);
$db->execute();
Thanks a lot in advance, cheers,
Marc