注册 登录
编程论坛 PHP技术论坛

为什么$conn->query("select * from user where username='".$username.&qu

无事学编程 发布于 2014-03-18 22:16, 2044 次点击
如题,这是《php与mysql web开发》这本书中的第一个例子,搜索了很久还是没有解决
下面是db_fns.php的代码:
?php
    function db_connect(){
        $result=new mysqli('localhost','root','','bookmarks');
        if(!$result){
            throw new Exception("Could not connect to the databases server!");
        }
        else{
            return $result;
        }
    }
?>
求助!!!!
2 回复
#2
fragileeye2014-03-26 13:52
我也正在学习这本书,首先你在mysql中得建一个bookmarks的表。
说白了,你得看懂这句 new mysqli('localhost', 'root', '', 'bookmarks');
localhost本机
root默认账户名
''密码为空
bookmarks ,mysql中有一个bookmarks的表
#3
asmdaydream2014-04-01 16:41
问题在哪 ?  搜索了很久还是没有解决,什么没有解决?
1