내 함수를 호출 할 때 MySQL 구문 오류가 나타납니다.MySQL 구문 오류 오류
SQL 구문에 오류가 있습니다. 올바른 구문 당신은 값을 닫지 않은 라인 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");
}
?>
을 보았을 것입니다. SQL 삽입 방지를 위해 PDO 또는 mysqli (매개 변수 쿼리)를 사용하십시오. –
@ Akam의 설명에 덧붙여, 'mysql'확장은 PHP 5.5에서 더 이상 사용되지 않으므로 대신 mysqli 또는 PDO를 사용하는 것이 좋습니다. 이것에 대한 자세한 내용은 http://www.php.net/manual/en/mysqlinfo.api.choosing.php를 참조하십시오. – Cokegod