一下子sql查询代码放入php为什么会空白呢

WBOY
發布: 2016-06-13 12:49:41
原創
872 人瀏覽過

一下sql查询代码放入php为什么会空白呢?
吧这段sql查询语句放入php就会空白是为什么呢?
语句在mysql查询没问题,可以显示查询结果的.

$sql = mysql_query('select attach.* , category.* from attach, category where attach.id = substring_index(substring_index(substr(category.ext,locate('"attach"',category.ext)),'"',4),'"',-1) order by rand() limit 5');

如果去掉
 substring_index(substring_index(substr(category.ext,locate('"attach"',category.ext)),'"',4),'"',-1)
就没问题,怎么解决呢?


------解决方案--------------------
你在被单引号括起的串中使用了未转义的单引号,难道不报错吗?

$sqlstr = select attach.* , category.* from attach, category where attach.id = substring_index(substring_index(substr(category.ext,locate('"attach"',category.ext)),'"',4),'"',-1) order by rand() limit 5
SQL;
$sql = mysql_query($sqlstr);
相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!