我如何追踪当我尝试使用Php进行删除时会发生什么?

时间:2013-04-05 19:30:21

标签: php

我有以下代码:

<?php
    // configuration
    require("../includes/config.php"); 

    // if form was submitted
    if($_GET['id'])
    {    
        $id = $_GET['id'];
        $id = mysql_escape_string($id);
        $sql = "DELETE FROM city WHERE id = $id";
        mysql_query($sql);
    }
?>

当我尝试从浏览器运行时,我收到一条错误消息:

http://localhost/delete.php&id=3
The requested URL /delete.php&id=3 was not found on this server

http://localhost/delete.php
 Notice: Undefined index: id in /home/localhost/html/delete.php on line 6

有人能告诉我如何追踪正在发生的事情。请注意,我运行的机器无法像fiddler那样运行

1 个答案:

答案 0 :(得分:3)

URL中传递的第一个参数必须用?分隔,所有后续参数都用&分隔(使用GET协议时)

您的网址格式必须为:

delete.php?ID = 3

使用表格的后续参数:

delete.php?id=3&name=foo&page=bar