当前位置:Gxlcms > PHP教程 > php数据库连接异常

php数据库连接异常

时间:2021-07-01 10:21:17 帮助过:3人阅读

php数据库连接错误
有代码如下:

$catid=intval($_REQUEST['catid']);
$sql_store = 'SELECT * FROM ecm_gcategory Where cate_id=$catid ORDER BY cate_id';
$my_category= DB::fetch_all($sql_store);

运行报如下错误:
SELECT * FROM ecm_gcategory Where cate_id=$catid ORDER BY cate_id


怎么解决哟?请高人指点!
------解决思路----------------------
$sql_store = "SELECT * FROM ecm_gcategory Where cate_id=$catid ORDER BY cate_id";
双引号!
------解决思路----------------------
单引号里面的变量不能被解析,需用双引号括起来。或者改成下面这样:
$sql_store = 'SELECT * FROM ecm_gcategory Where cate_id='.$catid.' ORDER BY cate_id';

人气教程排行