为什么会出现这个异常
程序员文章站
2022-05-26 22:21:09
...
为什么会出现这个错误
LNMP系统,php是5.3
代码如下
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")) {?相关文章
相关视频
上一篇: Markdown语法学习
下一篇: PHP扩展CURL的用法详解