php中关于sql拼接时标点符号出现的问题

WBOY
Release: 2016-06-23 13:57:25
Original
1215 people have browsed it

初学php,遇到了个奇怪的问题,让大侠们见笑了,拼接语句如下:

 $sql = 'select cat_id,cat_name,parent_id from ' . $this->table . ' where parent_id=' . $id;//能通过,正解  $sql = 'select cat_id,cat_name,parent_id from' . $this->table . 'where parent_id=' . $id;
Copy after login


为啥符号的空位不同,拼接的结果会有差异, 不解中,求解答?


回复讨论(解决方案)

你把两句输出之后对比下就知道了。
第一句.... from table where...
第一句.... fromtablewhere...

第二句中from 、table和where连在一起了,还能正确吗?

select cat_id,cat_name,parent_id fromcategorywhere parent_id=42delete from category where cat_id=42
Copy after login

跑的太快了,基础没打好,谢谢版主提醒!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!