-3

这里的每个人..现在我遇到了一个问题,所以请帮助我,因为我是 php 代码的新手。我想从 url 中获取值,但结果是未定义的索引

这是网址:http: //4you4me.com/admin/index_edit_form.php ?edit=76

php代码:

 if(isset($_REQUEST['edit']) === TRUE && ! empty($_REQUEST['edit']))
        $con_id_update = mysql_real_escape_string((int)$_REQUEST['edit']);
print_r($con_id_update);

结果是未定义的变量:con_id_update

这个脚本有什么问题?谢谢你的回答。

4

3 回答 3

0

You should get value from url using $_GET instead of $_REQUEST if you know exactly what you want, good luck!

于 2013-03-13T04:39:06.480 回答
0

看起来您缺少花括号:

if(isset($_REQUEST['edit']) === TRUE && ! empty($_REQUEST['edit'])) {
    $con_id_update = mysql_real_escape_string((int)$_REQUEST['edit']);
    print_r($con_id_update );
}

如果您不将花括号包裹在整个语句周围,则只会执行 if 语句之后的行。

于 2013-03-13T02:46:03.897 回答
0

try this :

$con_id_undate ='';// to initialize 

 if(isset($_GET['edit']) && !empty($_GET['edit']))
            $con_id_update = (int)$_GET['edit'];

    print_r($con_id_undate);

You shouldn't use $_REQUEST

Also you should use msqli instead of mysql. Since you cast the value to an int you don't need to use mysql_real_escape_string.

mysql_real_escape_string (mysqli_real_escape_string) tends to work only when their is already an open connection

于 2013-03-13T02:54:01.057 回答