INSERT INTO不会运行,除非发现$ re未定义,否则不会出现错误。它曾经工作过,但不再有效。MySQL查询不运行
$servername = "localhost";
$username = "id728908_njaohnt";
$password = "pass";
$dbname = "id728908_sub";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if (!$resu=$conn->query("SELECT confirmed FROM subscribers WHERE
email='".$email."'"))
{echo $conn->error;}
while ($row = $resu->fetch_assoc()) {
$resul=$row['confirmed'];}
$sql = "INSERT INTO subscribers (email) VALUES ('".$email."')";
if ($resul==null || $resul==0)
{
if ($resul!=0)
{
if ($conn->query($sql) === TRUE)
{
$res=$conn->query("SELECT A_I FROM subscribers WHERE email='".$email."'");
while ($row = $res->fetch_assoc()) {
$re=$row['A_I'];
...
$电子邮件是 $电子邮件= @trim(的stripslashes($ _ GET [ '电子邮件']));
您应该添加代码来检查INSERT INTO上的错误。另外考虑使用PDO而不是mysqli。 –
Mysqli是好的,但你确实需要使用参数化查询 – Strawberry
请使用预先准备好的语句以及'$ email'在哪里或什么地方? –