使用MySQLi将行插入MySQL数据库

时间:2013-04-04 06:19:18

标签: php mysql mysqli

有人可以发现错误:

mysqli_query($connection, "INSERT INTO comments (event_id, fulltext, date_posted) VALUES (5, 'Hallo', 430234)");

已建立连接,但它不会插入新行。

include("../../connect.php");

$event_id = intval($_GET["event_id"]);
$fulltext = $_GET["fulltext"];
$date = intval($_GET["date"]);

mysqli_query($connection, "INSERT INTO comments ('event_id', 'fulltext', 'date_posted') VALUES (5, 'Hallo', 430234)");

echo "INSERT INTO comments (event_id, fulltext, date_posted) VALUES (5, 'Hallo', 430234)";

mysqli_close($connection);

1 个答案:

答案 0 :(得分:5)

FULLTEXT mysql 中的保留字,您不能将其用作列名称,使用`列名称旁边的<{1}}

mysqli_query($connection, "INSERT INTO comments 
(`event_id`, `fulltext`, `date_posted`) VALUES (5, 'Hallo', 430234)");