$ _GET-我如何从路径中获取名称和类型?
问题描述:
in items.php
$filepath = mysql_real_escape_string($_GET['filepath']);
$name = mysql_real_escape_string($_GET['name']);
$type = mysql_real_escape_string($_GET['type']);
echo $name,$type;
echo '<td><a target=\"_blank\" href="'.$filepath.'" title=\"\">'.$filepath.'</a> ';
error:
Notice: Undefined index: name
Notice: Undefined index: type
result: images/ch1.pdf?name=number?type=Memo
i want to get the values from name and type.
答
You only use one question mark ?
and then seperate the variables with ampersands &
It should look like
images/ch1.pdf?name=number&type=Memo
答
If you pass your parameters to your script using GET like index.php?name=foo&type=bar
, you should be able to receive them in your PHP using $_GET
, so your code looks like it should work.
I suggest removing mysql_real_escape_string
. It may be screwing up your script.