作者kong0107 (阿空)
看板PHP
标题Re: [请益] 小问题
时间Tue Jul 31 15:30:35 2007
※ 引述《showsky (小小世界)》之铭言:
: ※ 引述《showsky (小小世界)》之铭言:
: : 预设PORT就是3306 不需要麻烦这样写
: : SQL语法错误 去掉分号select * from customers where name='$old_name'
: $str = "select * from `customers` where `name`='$old_name'";
加分号是没有问题的(虽然官网的确有提醒不要加)
另外identifier(就是table或column的名字)
只要不是SQL的关键字,也不用加backtick(`)
其实像是MDB2这类推广跨DBS的东西甚至会建议
应该设定table和column的名字的时候就不要使用关键字
(可参见
http://pear.php.net/manual/en/package.database.mdb2.intro-quote.php )
至於原po的问题,我在想会不会是根本没有连到资料库或是登入失败
(但那样应该也会有connection failure的php warning... @.@)
可以试一下在mysql_connect()和mysql_query()的後面都加一行
if(mysql_errno()) echo mysql_error(), "<br />\n";
--
只要抓住他那根尾巴
就可以让他服服贴贴的
http://www.streetvoice.com.tw/kong0107/music
--
※ 编辑: kong0107 来自: 218.170.118.31 (07/31 15:33)
1F:→ kong0107:顺便检查一下table name有没有拼错吧..也许是customer ?? 07/31 15:34
2F:→ kong0107:另外建议原po下次要用好一点的标题唷 07/31 15:38