I have this php code:
$db = new mysql;
$new_bad = $_POST['new_bad'];
$new_replace = $_POST['new_replace'];
if ($_POST['submit']) {
if ($new_bad && $new_replace) {
$db->query("SELECT * FROM BAD_WORDS WHERE BAD_WORD='".$new_bad."'");
if ($db->CNrows() == 0) {
$db->query("
INSERT INTO BAD_WORDS(BAD_WORD,REPLACE)
VALUE('".$new_bad."','".$new_replace."')
");
$err = "added succesfully..";
$tmp->assign('msg', 'true');
} else {
$err = "the word is in table ..!!";
$tmp->assign('msg', 'false');
}
} else {
$err = "you must fill all feilds ..!!";
$tmp->assign('msg', 'false');
}
}
but when I test it i found this 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 'REPLACE) VALUES('bad1','replace1')' at line 1
what's the problem??
$tmp->
= it's smarty template class and work with no problems
BAD_WORDS
table = ID,BAD_WORD,REPLACE