尽管传递了'id',删除功能仍未执行

时间:2015-01-29 11:50:39

标签: php html pdo

我有这段代码,显示收据页面中的记录。

 <?Php
    require "config.php";           

    $page_name="currentout.php";  
    $start=$_GET['start'];
    if(strlen($start) > 0 and !is_numeric($start)){
    echo "Data Error";
    exit;
    }


    $eu = ($start - 0); 
    $limit = 10;                                 
    $this1 = $eu + $limit; 
    $back = $eu - $limit; 
    $next = $eu + $limit; 

    $nume = $dbo->query("select count(id) from receipt")->fetchColumn();


    echo "<TABLE class='t1'>";
    echo  "<tr><th>ID</th><th>Name</th><th>Pass</th><th>Amount</th><th>Action</th></tr>";


    $query=" SELECT * FROM receipt  limit $eu, $limit ";


    foreach ($dbo->query($query) as $row) {

    @$m=$i%2;
    @$i=$i+1;   
    echo "<tr class='r$m'><td>$row[id]</td><td>$row[name]</td><td>$row[phone_num]</td><td>$row[Amount]</td><td><a href='delete.php?id=$row[id]'>delete</a></td></tr>";
    }
    echo "</table>";

    if($nume > $limit ){ 
    echo "<table align = 'center' width='50%'><tr><td  align='left' width='30%'>";

    if($back >=0) { 
    print "<a href='$page_name?start=$back'><font face='Verdana' size='2'>PREV</font></a>"; 
    } 

    echo "</td><td align=center width='30%'>";
    $i=0;
    $l=1;
    for($i=0;$i < $nume;$i=$i+$limit){
    if($i <> $eu){
    echo " <a href='$page_name?start=$i'><font face='Verdana' size='2'>$l</font></a> ";
    }
    else { echo "<font face='Verdana' size='4' color=red>$l</font>";}        
    $l=$l+1;
    }


    echo "</td><td  align='right' width='30%'>";

    if($this1 < $nume) { 
    print "<a href='$page_name?start=$next'><font face='Verdana' size='2'>NEXT</font></a>";} 
    echo "</td></tr></table>";

    } 
    ?>

这是链接的delete.php的代码。

<?php
require "config.php";
$pdo="null";
$sql = "DELETE FROM receipt  WHERE ID=  :ID";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':ID', $_GET['id'], PDO::PARAM_INT);  
$stmt->execute($sql);
       echo "Record deleted successfully";


   header('location: currentout.php');
?>

'id'被传递到删除页面但删除功能没有执行。有人可以帮助发现delete.php中的错误吗?

1 个答案:

答案 0 :(得分:2)

您将$pdo设置为&#39; null&#39;然后你尝试将它用作对象。启用错误报告,您会看到相关的错误消息。