-1

私の関数を呼び出すと、MySQL 構文エラーが表示されます。何かアイデアはありますか?

SQL 構文にエラーがあります。1 行目の near '' を使用する正しい構文については、MySQL サーバーのバージョンに対応するマニュアルを確認してください。

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");
}
?>
4

2 に答える 2