Home  >  Article  >  Backend Development  >  WinInet模拟HTTP的POST请求报错

WinInet模拟HTTP的POST请求报错

WBOY
WBOYOriginal
2016-06-13 11:59:47896browse

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']); 试试
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn