我不明白为什么这不起作用。它说“添加备注”,但它实际上并没有将其添加到数据库中。mysql插入故障
<?php
$notetitle = $_POST['title'];
$notebody = $_POST['body'];
if ($notetitle && $notebody){
mysql_query("insert into notes values
('$user_id', '', '$subject', '$notetitle', '$note_type' '$notebody')");
echo "Note \"" . $notetitle . "\" added.";
}
>
请注意,一旦它进入if($ notetitle ...),它将始终执行回显,即使它没有被插入。 – Nobita
不要忘记保护自己免受mysql注入(使用mysql_real_escape_string()http://php.net/manual/en/function.mysql-real-escape-string.php)。 – s3v3n