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'在哪裏或什麼地方? –