我的一段php网页代码的sql语句死活出不来,求大神帮助
<formname="zwj_form1"method="post"action="index.php"><inputid="zwj_save"type="submit"...
<form name="zwj_form1" method="post" action="index.php">
<input id="zwj_save" type="submit" value="0-200" />
<input id="text" name="zwj_text_bt" type="text" style="display:none" value="jiage>=0 and jiage < 200"/>
</form>
<?php
连接数据库语句省略
$zwj_tijiao_jiaqian=$_POST["zwj_text_bt"];
$result=mysql_query("select * from zwj_spb where jiage>=0"."$zwj_tijiao_jiaqian"."order by jiage desc;",$conn);
$rows=mysql_num_rows($result);
echo $rows;
?>
报这个错 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource inC:\wamp\www\xiangmu\index.phpon line144
如果把order by jiage desc这个去掉就对了,求大神指教!! 展开
<input id="zwj_save" type="submit" value="0-200" />
<input id="text" name="zwj_text_bt" type="text" style="display:none" value="jiage>=0 and jiage < 200"/>
</form>
<?php
连接数据库语句省略
$zwj_tijiao_jiaqian=$_POST["zwj_text_bt"];
$result=mysql_query("select * from zwj_spb where jiage>=0"."$zwj_tijiao_jiaqian"."order by jiage desc;",$conn);
$rows=mysql_num_rows($result);
echo $rows;
?>
报这个错 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource inC:\wamp\www\xiangmu\index.phpon line144
如果把order by jiage desc这个去掉就对了,求大神指教!! 展开
3个回答
展开全部
SQL语句错误。
$result=mysql_query("select * from zwj_spb where jiage>=0"."$zwj_tijiao_jiaqian"."order by jiage desc;",$conn);
其中变量部分$zwj_tijiao_jiaqian='jiage>0 and jiage<200';
那么替换后你的SQL语句是:
select * from zwj_spb where jiage>=0 jiage>0 and jiage<200 order by jiage desc
是不是有问题了?
正确的语法是:
$result=mysql_query("select * from zwj_spb where {$zwj_tiaojian_jiaqian} order by jiage desc",$conn);
展开全部
$result=mysql_query('select * from `zwj_spb` where `jiage` >= 0' . $zwj_tijiao_jiaqian . ' order by jiage desc',$conn);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
$result=mysql_query("select * from zwj_spb where jiage>=0"."$zwj_tijiao_jiaqian"."order by jiage desc;",$conn);问题在于你没留空格,其实以后有这样的问题你直接echo它出来就知道问题在哪里
//改为:
$result=mysql_query("select * from zwj_spb where jiage>=0 ${zwj_tijiao_jiaqian} order by jiage desc;",$conn);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询