PHP MySQLi INSERT不插入数据

时间:2015-03-19 14:24:19

标签: php mysql mysqli

我正在尝试将mysqli插入到数据库表中,连接正常,$ _GET ['emailaddress']已填充,表存在,它只是没有插入数据。

$connection = mysqli_connect("localhost","database","password");

mysqli_select_db($connection, "database");

if (mysqli_connect_errno()) {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
        die;
}else{
        echo 'success';
}

mysqli_query($connection, "INSERT INTO `campaign` (`email`) VALUES ('" . $_GET['emailaddress'] . "'");

mysqli_close($connection);

1 个答案:

答案 0 :(得分:4)

您缺少1个括号

mysqli_query($connection, "INSERT INTO `campaign` (`email`) VALUES ('" . $_GET['emailaddress'] . "')");