請幫助解決該問題:刪除文件夾和數據庫 - PHP
注意:未定義的變量:ID在d:\ MyWebSite \ css_pro \ ADMIN \核心\上線de_products_test.php 6
注意:未定義的變量:ID中d:\ MyWebSite \ css_pro \管理員\芯\上線de_products_test.php 17
代碼:
session_start();
require("../../inc/con_db.php");
$qry=mysql_query("SELECT * FROM products WHERE id='$id'");
$row=mysql_fetch_array($qry);
if($row["img_thumb"]!="") {
$thum=$row["img_thumb"];
unlink("/images/products/thumbs/".$thum);
}
if($row["img_larg"]!="") {
$larg=$row["img_larg"];
unlink("/images/products/".$larg);
}
$delete="DELETE FROM products WHERE id='$id' ";
$result=mysql_query($delete);
if($result==1) {
print "Entry delete success";
} else {
print "Entry delete failed";
}
您在哪裏定義$ id?因爲它聲明$ id是未定義的。你是不是使用註冊全局變量是你? – Najzero
您的代碼易受SQL注入攻擊。 – Daedalus