您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

mysql_query()中的sql语句好像不能带括号

2024/6/3 11:15:23发布43次查看
sql
$rs= mysql_query(select * from cxjb2 where nam .$_post[select3]. $_post[nam] and cat .$_post[select0]. $_post[cat] and sha .$_post[select1]. $_post[sha] and pri is null  or nam .$_post[select3]. $_post[nam] and cat .$_post[select0]. $_post[cat] and sha .$_post[select1]. $_post[sha]);
以上语句可以执行。
$rs= mysql_query((select * from cxjb2 where nam .$_post[select3]. $_post[nam] and cat .$_post[select0]. $_post[cat] and sha .$_post[select1]. $_post[sha]) and (pri is null  or pri is not null));
同样的逻辑关系转换成此语句时便不能成功执行了。
请问各位大大指教
回复讨论(解决方案)  $rs= mysql_query((select * from cxjb2 where nam .$_post[select3]. $_post[nam] and cat .$_post[select0]. $_post[cat] and sha .$_post[select1]. $_post[sha]) and (pri is null  or pri is not null));
就是
 $rs= mysql_query((...) and (...));
你说这样对吗?
就是这样!
while($rst = mysql_fetch_row($rs)){
加了括号后此行程序报错
warning: mysql_fetch_row(): supplied argument is not a valid mysql result resource in e:\apache\htdocs\chashi2.php on line 329
就是这样!?
语法都不对了,还不报错吗?
恕我眼拙
我知道语法肯定错了
只是不知道哪里错了
所有的sql指令都必须以 sql 命令字开头
我悟了 谢谢大大的指教
$rs= mysql_query(select * from cxjb2 where (nam .$_post[select3]. $_post[nam] and cat .$_post[select0]. $_post[cat] and sha .$_post[select1]. $_post[sha]) and (pri is null  or pri is not null));
我把括号位置改变后成功了。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product