时间:2021-07-01 10:21:17 帮助过:4人阅读
$result = mysql_query($query);
$top = $_REQUEST['top'];
数据库连接正确吗?
数据库连接正确吗?
另有一个同样的模拟HTTP请求,也有参数,返回就是正确的:
void CDllValidateDlg::ValidateAPerson(char* Name, char* Code){ CString post_data; post_data.Format("userid='%s'&name='%s'",Code,Name); //请求的附加参数 CString result; //返回的结果 CString post_page = "test_id_validater/validateid.php"; //请求的php PostHttpPage(result,post_page,post_data); AfxMessageBox(result);}
void CDllValidateDlg::getActs(HTREEITEM root){ CString post_data="top=0";// char top[10];// itoa(ActivitiesTree.GetItemData(root),top,10);// post_data.Format("top=%s",top); CString result; CString post_page = "test_id_validater/GetActivities.php";// AfxMessageBox("post_page:"+post_page+", "+"post_data:"+post_data); PostHttpPage(result, post_page, post_data); AfxMessageBox(result); …… ……
感觉好像是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
这个信息分明是数据库报的错!
如果 $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']); 试试