PDA

View Full Version : function is not working


Bob42
04-19-2008, 04:37 PM
I'm having problems getting my function to work. I receive this error:


Error: 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 'mod, action, value1) VALUES ('Fox', 'Remove Banned IP', '--')' at line 1

Here is my function:


function addModLog ($mod, $action, $value1) {
$log = mysql_query("INSERT INTO moderator_logs (mod, action, value1) VALUES ('$mod', '$action', '$value1')");
if ($log) {
$result = 'Data logged...';
return $result;
}
else {
$result = 'Error: '.mysql_error();
return $result;
}
}



if (isset($_GET['ipremove'])) {
removeIP($_GET['ipremove']);
echo addModLog($session['username'],'Remove Banned IP','--');
}

I reviewed the code multiple times, and I can't find the error.

PappaJohn
04-19-2008, 04:40 PM
mod is a reserved word, you're better off not using it as a column name.

If you insist on using it, you'll have to wrap it in backticks: `mod`