传递数据出错了吗?
view中: 标题:<?=anchor("message/enter/$row->id","$row->title");?>点击后url:http://localhost/ci/index.php/message/enter/17,controller的enter():
$id = $this->uri->segment(3);
$sql = 'select * from entries where id = '+$id;
$data['message'] = $this->db->query($sql);
出现错误:
A Database Error OccurredError Number: 1064You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '17' at line 117Filename: C:\wamp\www\ci\system\database\DB_driver.phpLine Number: 330
$sql = 'select * from entries where id = '+$id;
=》
$sql = 'select * from entries where id = '.intval($id); 太尉天上飞 发表于 2012-8-26 01:10 static/image/common/back.gif
$sql = 'select * from entries where id = '+$id;
=》
谢谢~ 链接字符串问题,“+”是js链接字符串;“.”是php程序链接字符串。。。。
页:
[1]