首頁  >  文章  >  後端開發  >  WinInet模拟HTTP的POST请求报错

WinInet模拟HTTP的POST请求报错

WBOY
WBOY原創
2016-06-13 11:59:47895瀏覽

WinInet模拟HTTP的POST请求出错

本帖最后由 dimply 于 2014-06-09 14:02:10 编辑 在VS2012里面设置断点跟踪执行,发现请求该php文件获取的不是正确的返回字串,而是如下出错信息:

Invalid query: 
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Whole query: 
select id,name from index_activities where top=0

这段信息是我在PHP的
$result = mysql_query($query);

语句行后面,“if”请求不成功才输出的,显然是mysql请求没成功,且可以确定,调用该PHP文件是成功的。

但是当我在网页中用同样的参数调用同一个PHP文件时(GET方式),返回值则是正确的。

我php文件中获取传参是用的
$top = $_REQUEST['top'];

所以POST和GET参数应该都可以同样获取的。

不知道可能是哪里出了问题?用WinInet传参会造成这个请求字串有什么异常吗?
------解决方案--------------------
Invalid query: 
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Whole query: 
select id,name from index_activities where top=0
这个信息分明是数据库报的错!

如果 $query = "select id,name from index_activities where top=0"; 可以
而 $query = "select id,name from index_activities where top=$top"; 不可以
这就表示 $top 无值或不是数字
------解决方案--------------------
$top = $_REQUEST['top']; 改为 $top = intval($_REQUEST['top']); 试试
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn