调用我的函数时出现 MySQL 语法错误,有什么想法吗?
您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的 '' 附近使用正确的语法
function getComments1() {
$query = mysql_query("SELECT * FROM comments") or die(mysql_error());
while($post = mysql_fetch_assoc($query)) {
echo $post['Author'];
}
}
function addComment($cName, $cContent) {
$query = mysql_query("INSERT INTO comments VALUES(null,'$cName','$cContent'") or die(mysql_error());
}
<?php
include('includes/functions.php');
mysql_set_charset ( "utf8" );
if(isset($_POST['submit'])) {
if(isset($_POST['CommentName'])) {
if(isset($_POST['CommentContent'])) {
addComment($_POST['CommentName'],$_POST['CommentContent']);
header("Location: derger.php");
} else { "text missing";
}
} else {
echo "name missing";
include('herger.php');
}
} else {
header("Location: werger.php");
}
?>