2012-09-17 7 views
-6

문제 해결을 위해 도와주세요 : D에 ID :폴더 및 데이터베이스에서 삭제 - PHP

공지 사항 : 정의되지 않은 변수 라인 \ MyWebSite \ css_pro \ 관리 \ 코어 \의 de_products_test.php 6

공지 사항 : 정의되지 않은 변수 : D에 ID : 라인 \ 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"; 
} 
+1

여기서 $ id는 어디에 정의합니까? 그것은 $ id가 정의되지 않았기 때문입니다. 너는 너를 등록 전역이라고 너를 사용하고 있지 않는가? – Najzero

+1

코드가 SQL 삽입 공격에 취약합니다. – Daedalus

답변

1

if(isset($id)) 
{ 
    // your query 
} 
+0

하지만 이미지는 여전히 디렉토리에서 삭제되지 않습니다. –

+0

이미지 제공 경로가 올바른지 확인하십시오. –

+0

예, 이미지 경로가 정확합니다. 예를 들어 제발 할 수 있니? –