在php中发送加号获取url参数

时间:2014-09-18 08:39:34

标签: php postgresql sql-injection

我在网址发送参数。但是当试着写" 0 + 880" url中的变量查询失败。这是问题,这里是我的一些代码

$table = $_GET['table'];
$yerId= $_GET['km'];

$sql = pg_query("SELECT  turu, hat_kesimi, ili, ilcesi, mahadi FROM $table WHERE km = $yerId");
if (!$sql) { 
    echo "Problem with query " . $sql . "<br/>"; 
    echo pg_last_error(); 
    exit(); 
}             

这是url&go; google返回的网址:

/weekend/index.php?dbname=tcdd&table=hemzemin_gecit&km=0^880#tab-1
谷歌反应:

查询问题

ERROR: operator does not exist: character varying = double precision 
LINE 1: ...mi, ili, ilcesi, mahadi FROM hemzemin_gecit WHERE km = 0^880 
                                                                ^ 
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

另一个网址:

/weekend/index.php?dbname=tcdd&table=hemzemin_gecit&km=0%2B880#tab-1
谷歌反应:

查询问题

ERROR: operator does not exist: character varying = integer 
LINE 1: ...mi, ili, ilcesi, mahadi FROM hemzemin_gecit WHERE km = 0+880 
                                                                ^ 
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

3 个答案:

答案 0 :(得分:2)

这么多错误。让我们从:

开始

请:use PDOat least pg_query_params

答案 1 :(得分:1)

在你的情况下,你应该使用:

 rawurlencode() 

对网址进行编码,

rawurldecode()

解码它。

答案 2 :(得分:0)

发送参数时,你应该对它们进行URLEncode&#34;&#34; 0 + 880&#34; shoudl go as&#34; 0%2B880&#34;否则它会与网址混淆。

链接以快速编码/解码值以进行调试/测试。 http://meyerweb.com/eric/tools/dencoder/