从文件夹和数据库中删除 - php

时间:2012-09-17 05:34:08

标签: php

请帮助解决问题:

  

注意:第6行的D:\ MyWebSite \ css_pro \ admin \ core \ de_products_test.php中的未定义变量:id

     

注意:未定义的变量:第17行的D:\ MyWebSite \ css_pro \ admin \ core \ de_products_test.php中的id

代码:

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";
}

1 个答案:

答案 0 :(得分:1)

使用

检查$ id变量
if(isset($id))
{
     // your query
}