php页面运行出错,求高手解决! 20

出错页面显示:YouhaveanerrorinyourSQLsyntax;checkthemanualthatcorrespondstoyourMySQLserverve... 出错页面显示: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

出错页面php代码:

<?
require_once ("top.php");
require_once ("foot.php");
require_once ("mem_left.php");
if(!empty($_COOKIE['uname']) && !empty($_COOKIE['uid'])){

$sql ="select count(id) as a ,sum(pprice) as b from card_cart where uid=".$_COOKIE['uid'];
$member = $mydb->getRow("select * from card_users where user_id =".$_COOKIE['uid']."");
$mcount = $mydb->getRow("select count(id) as a ,sum(pprice) as b from card_cart where uid=".$_COOKIE['uid']);

} else {
echo "<script>alert('请先登录');</script><br>";
echo "<script>location.href='index.php'</script>";
}
//setcookie("ECS","");
$key = $_REQUEST['keyword'];
require_once("./config/page.class.php");
$sqlwhere = " 1 and uid = $uid ";
$uid = $_COOKIE['uid'];
if(!empty($key)) $sqlwhere .= " and pname like '%$key%'";
$news= new page(10,$mydb->link_id,"card_cart","id",$sqlwhere,7,"keyword=$key" );
$sq=$news->display();
if($news->num=='0') { $msg="无信息!"; } else {
while(@$cartlist2=@mysql_fetch_assoc($sq)){
$cartlist2['pcount'] = $cartlist2['pprice'] * $cartlist2['pnum'];
//$cartlist2['yh']=explode($cartlist2['pgongyi']);
//$yh[] = $cartlist2['pgongyi'];
$yh[]=explode('|',$cartlist2['pgongyi']);
$cartlist[]=$cartlist2;
}
$pagelist = $news->press();
}
if($_REQUEST['action']=='del' && $_REQUEST['id']!='' && is_numeric($_REQUEST['id'])){
$ss = "delete from card_cart where id=".$_REQUEST['id']." and uid=". $_COOKIE['uid'];
$cc = $mydb->query($ss);
if($cc){
$msg="删除成功!";
echo "<script>alert('$msg');</script>";
echo "<script>location.href='cartindex.php';</script>";
} else {
$msg="删除失败!";
}
}
//print_r($yh);exit;
/*****
foreach($cartlist as $value){
$pricecount=$value[pprice]*$value[pnum];
$pricecount2[]=$pricecount;
}
****/
//require_once("./cart.class.php");
//$cart= new cart();
//$cart_info = $cart->cartAdd('s','2');
//$smarty->assign('contacts', $db->getAll($sql));
$smarty->assign("member",$member);
$smarty->assign("yh",$yh);
$smarty->assign("mcount",$mcount);
$smarty->assign("msg",$msg);
$smarty->assign("pagelist",$pagelist);
$smarty->assign("cartlist",$cartlist);
$smarty->assign("pricecount",$pricecount2);
$smarty->display("cartindex.html");
?>
展开
 我来答
dingdang0702
2012-03-28 · TA获得超过384个赞
知道小有建树答主
回答量:375
采纳率:100%
帮助的人:245万
展开全部
$sql ="select count(id) as a ,sum(pprice) as b from card_cart where uid=".$_COOKIE['uid'];
应该是$_COOKIE['uid']没有值,所以sql语句结构不完整。
可以
echo $sql;return;
输出sql查看一下
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
zft610
2012-03-25 · TA获得超过110个赞
知道答主
回答量:72
采纳率:100%
帮助的人:42.5万
展开全部
sql语法有问题,在SQL服务器的命令行方式下检查下SQL语句是否正确.
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
qq453655422
2012-03-25 · 超过12用户采纳过TA的回答
知道答主
回答量:97
采纳率:0%
帮助的人:50.5万
展开全部
看不了这么长的代码,因该是sql语句的问题,你看报错的提示,根据他来检查你的错误
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
小鱼不等于零
2012-03-25 · 超过19用户采纳过TA的回答
知道答主
回答量:50
采纳率:0%
帮助的人:48.5万
展开全部
$sql ="select count(id) as a ,sum(pprice) as b from card_cart where uid=".$_COOKIE['uid'];
我认为可能是少了引号 count('id') sum('pprice')
建议你先在phpmyadmin里测试sql语句。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
匿名用户
2012-03-25
展开全部
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(3)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式