欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

为什么会出现这个异常

程序员文章站 2022-06-03 09:57:53
...
为什么会出现这个错误
LNMP系统,php是5.3

代码如下

class db{?
????????private $_link;
??????????
????????function __construct($dbhost='localhost',$dbuser='root',$dbpassword='',$dbname='test',$charset='utf-8') {?
????????????$this->_link = mysql_connect($dbhost,$dbuser,$dbpassword,true);?
????????????$this->_link or $this->errmsg('无法连接MYSQL服务器!');?
????????????if ($this->version() > '4.1') {?????????????????
????????????????$this->query('set names '.$charset);????????
????????????}?
????????????
????????????mysql_select_db($dbname,$this->_link) or $this->errmsg('无法连接数据库!');?
????????}?
??????????
????????
????????public function query($sql) {??????????????????????????????????????????????????????????????
????????????$result = mysql_query($sql,$this->_link);?
????????????$result or $this->errmsg('执行SQL语句错误!');?
????????????return $result;?
????????}
???????????
????????
????????
????????
????????
????????public function fetch_array($result,$type = MYSQL_ASSOC) {
????????????return mysql_fetch_array($result,$type);????
????????}
???????????
????????
????????public function fetch_object($result) {?
????????????return mysql_fetch_object($result);?
????????}
???????????
????????
????????public function affected_rows() {?
????????????return mysql_affected_rows($this->_link);?
????????}?
??????????
????????
????????public function free_result($result) {?
????????????return mysql_free_result($result);??
????????}?
??????????
????????
????????public function num_rows($result) {?
????????????return mysql_num_rows($result);?
????????}
????????????
????????
????????public function num_fields($result) {?
????????????return mysql_num_fields($result);?
????????}?
??????????
????????
????????public function insert_id() {?
????????????return mysql_insert_id($this->_link);?
????????}
???????????
????????
????????private function errmsg($msg) {?
????????????$message? = '一个MySQL错误发生!
';?
????????????$message .= '错误号:'. mysql_errno($this->_link) .'
';?
????????????$message .= '错误描述:'. $msg . mysql_error($this->_link) .'
';?
????????????$message .= '错误时间:'. date('Y-m-d H:i:s');?
????????????exit($message);?
????????}
???????????
????????
????????public function link_id() {?
????????????return $this->_link;?
????????}
????????????
????????
????????public function version() {?
????????????return mysql_get_server_info($this->_link);?
????????}?
??????????
????????
????????function getip() {?
????????????if(getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown")) {?
????????????????$ip = getenv("HTTP_CLIENT_IP");?
????????????}elseif(getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown")) {?
为什么会出现这个异常

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频