So, I'm using PHP-Fusion (for those 'not in the know,' it's a free content management system) as the foundation of a client's site. Because of their demands, I've had to both install addons (no big deal) and modify both the addons and original Fusion code, as well as create my own custom registration form in order to meet those demands. Nothing too difficult, but wading through Fusion's spaghetti code grows frustrating.
So, I'm at the point of testing my registration form with the database. I can get two somewhat complex INSERT queries to work, but the simple one keeps sending me an error, and it's driving me nuts.
The query in question is:
INSERT INTO fusion_aw_ec_events (ev_allow_logins) VALUES ('1') WHERE ev_id='11'
ev_allow_logins is just a simple TINYINT(1) column. ev_id, I believe, is just a SMALLINT(5) column.
The code I'm using to create and run this query is:
$query = "INSERT INTO ".DB_PREFIX."aw_ec_events (ev_allow_logins) VALUES ('1') WHERE ev_id='".$ev_id."'";
$result = dbquery($query);
dbquery() is a built-in Fusion function. It's nothing fancy:
function dbquery($query) {
$result = @mysql_query($query);
if (!$result) {
echo mysql_error();
return false;
} else {
return $result;
}
}
That shouldn't be the cause of my error.
The error I keep getting is:
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 'WHERE ev_id='11'' at line 1
But I'm not seeing any syntax errors, unless you can't have a WHERE clause in an INSERT.
Any ideas?
Posts
I would highly recommend bookmarking the MySQL documentation so you can check the correct syntax of everything.
Ah, thanks man!