首页 > 代码库 > mysqli,Fatal error
mysqli,Fatal error
<?php//mysql数据库类-mysqli版//2014/6/13class 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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。