码迷,mamicode.com
首页 > 数据库 > 详细

mysqli,Fatal error

时间:2014-06-15 06:05:13      阅读:444      评论:0      收藏:0      [点我收藏+]

标签:style   class   blog   code   color   get   

<?php
//mysql数据库类-mysqli版
//2014/6/13
class  mysqlidb{
     public $dbhost;
     public $dbuser;
     public $dbpasswd;
     public $dbname;
     public $dbport;
     public $dbobject;

     public function __contruct($host,$user,$pwd,$dbname,$port=3306){
         $this->dbhost = $host;
         $this->dbuser = $user;
         $this->dbpasswd = $pwd;
         $this->dbname = $dbname;
         $this->dbport = $port;
         
         $this->dbobject = new mysqli($this->dbhost,$this->dbuser,$this->dbpasswd,$this->dbname,$this->dbport);
           if ( $this->dbobject -> connect_error ) {
         die( ‘Connect Error (‘  .  $this->dbobject -> connect_errno  .  ‘) ‘
             .  $this->dbobject -> connect_error );
         }

     }

     public function executesql($sql,$param=array()){
         $dbstmt = $this->dbobject->prepare($sql);
         if(!empty($param)){
           foreach($param as $k => $v){
                $dbstmt -> bind_param($k,$v);
           }
         }
         $dbstmt -> execute();
         $dbresult = $dbstmt -> get_result();
         return  $dbresult->fetch_array();
     
     }

}

$db = new mysqlidb(‘127.0.0.1‘,‘root‘,‘‘,‘mysql‘);
$sql = ‘select * from User‘;
$dbrs = $db->executesql($sql);


//Fatal error: Call to a member function prepare() on a non-object in C:\xampp\htdocs\tonglei\mysqli\demo2.php on line 28

 

mysqli,Fatal error,布布扣,bubuko.com

mysqli,Fatal error

标签:style   class   blog   code   color   get   

原文地址:http://www.cnblogs.com/dytl/p/3786172.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!