Home > Backend Development > PHP Tutorial > 为什么会出现这个异常

为什么会出现这个异常

WBOY
Release: 2016-06-13 10:59:33
Original
1046 people have browsed it

为什么会出现这个错误
LNMP系统,php是5.3

代码如下

<br><?php <br />class db{? <br>????????private $_link;<br>??????????<br>????????function __construct($dbhost='localhost',$dbuser='root',$dbpassword='',$dbname='test',$charset='utf-8') {? <br>????????????$this->_link = mysql_connect($dbhost,$dbuser,$dbpassword,true);? <br>????????????$this->_link or $this->errmsg('无法连接MYSQL服务器!');? <br>????????????if ($this->version() > '4.1') {????????????????? <br>????????????????$this->query('set names '.$charset);???????? <br>????????????}? <br>????????????<br>????????????mysql_select_db($dbname,$this->_link) or $this->errmsg('无法连接数据库!');? <br>????????}? <br>??????????<br>????????<br>????????public function query($sql) {?????????????????????????????????????????????????????????????? <br>????????????$result = mysql_query($sql,$this->_link);? <br>????????????$result or $this->errmsg('执行SQL语句错误!');? <br>????????????return $result;? <br>????????} <br>???????????<br>????????<br>????????<br>????????<br>????????<br>????????public function fetch_array($result,$type = MYSQL_ASSOC) {<br>????????????return mysql_fetch_array($result,$type);???? <br>????????} <br>???????????<br>????????<br>????????public function fetch_object($result) {? <br>????????????return mysql_fetch_object($result);? <br>????????} <br>???????????<br>????????<br>????????public function affected_rows() {? <br>????????????return mysql_affected_rows($this->_link);? <br>????????}? <br>??????????<br>????????<br>????????public function free_result($result) {? <br>????????????return mysql_free_result($result);?? <br>????????}? <br>??????????<br>????????<br>????????public function num_rows($result) {? <br>????????????return mysql_num_rows($result);? <br>????????}<br>????????????<br>????????<br>????????public function num_fields($result) {? <br>????????????return mysql_num_fields($result);? <br>????????}? <br>??????????<br>????????<br>????????public function insert_id() {? <br>????????????return mysql_insert_id($this->_link);? <br>????????} <br>???????????<br>????????<br>????????private function errmsg($msg) {? <br>????????????$message? = '<strong>一个MySQL错误发生!</strong><br>';? <br>????????????$message .= '<strong>错误号:</strong>'. mysql_errno($this->_link) .'<br>';? <br>????????????$message .= '<strong>错误描述:</strong>'. $msg . mysql_error($this->_link) .'<br>';? <br>????????????$message .= '<strong>错误时间:</strong>'. date('Y-m-d H:i:s');? <br>????????????exit($message);? <br>????????} <br>???????????<br>????????<br>????????public function link_id() {? <br>????????????return $this->_link;? <br>????????}<br>????????????<br>????????<br>????????public function version() {? <br>????????????return mysql_get_server_info($this->_link);? <br>????????}? <br>??????????<br>????????<br>????????function getip() {? <br>????????????if(getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown")) {? <br>????????????????$ip = getenv("HTTP_CLIENT_IP");? <br>????????????}elseif(getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown")) {? <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template