我已升级到PHP 7并且我已将所有MySQL功能更新到MySQLi并进行了一些小的调整,我所改变的大部分内容都是在这个类中的dblayer:
/*
* A DATABASE LAYER THAT HELPS PROGRAM EASILY MERGE WITH DIFFERENT DATABASE SERVERS
*/
class dblayer {
public $dbtype;
public $dbhost;
public $dbuser;
public $dbpass;
public $dbname;
private $dbconn;
public function __construct() {
$this->dbconn = false;
$this->dbtype = 'mysql';
$this->dbhost = 'localhost';
$this->dbuser = '';
$this->dbpass = '';
$this->dbname = '';
}
/*
* CREATES A CONNECTION TO THE SERVER AND DATABASE
*/
public function connect() {
if (! $this->dbconn) {
switch ($this->dbtype) {
case 'mysql' :
$this->dbconn = mysqli_connect ( $this->dbhost, $this->dbuser, $this->dbpass, $this->dbname );
if (mysqli_connect_error ())
die ( 'ERROR CONNECTING TO DATABASE. CONNECT ERROR (' . mysqli_connect_errno () . ') ' . mysqli_connect_error () );
break;
}
}
}
/*
* A GENERIC SELECT QUERY WITCH RETURNS A MULTIDIMENSIONAL RESULTS ARRAY
*/
public function select_query($sql) {
$results = array ();
if ($this->dbconn) {
switch ($this->dbtype) {
case 'mysql' :
$query = mysqli_query ( $this->dbconn, $sql );
if (mysqli_num_rows ( $query ) > 0) {
while ( $row = mysqli_fetch_assoc ( $query ) ) {
$results [] = $row;
}
} else {
$results = false;
}
break;
default :
break;
}
}
return $results;
}
/*
* BASIC MODIFCATION QUERY SUCH AS UPDATE OR DELETE
*/
public function modify_query($sql) {
if ($this->dbconn) {
switch ($this->dbtype) {
case 'mysql' :
mysqli_query ( $this->dbconn, $sql );
break;
}
}
}
/*
* BASIC INSERT QUERY RETURNS NEW INCRIMENTED ID
*/
public function insert_query($sql) {
$returnid = 0;
if ($this->dbconn) {
switch ($this->dbtype) {
case 'mysql' :
mysqli_query ( $this->dbconn, $sql );
$returnid = mysqli_insert_id ( $this->dbconn );
break;
}
}
return $returnid;
}
/*
* CLOSES DATABASE CONNECTION ON SCRIPT END
*/
public function __destruct() {
if ($this->dbconn) {
switch ($this->dbtype) {
case 'mysql' :
mysqli_close ( $this->dbconn );
break;
}
}
}
}
我已经尝试寻找最明显的答案,问题可能在其他地方。我会继续找到问题,但如果你发现任何可能有帮助或需要修理的事情,请告诉我。
--- ---编辑
Rivition1
我用这个来做一些事情,但我的问题是当我尝试创建一个新用户但在网站上当我尝试创建新用户时它会带你进入&#34 ;签署阶段,"但是当您退出时,您无法登录。我已检查过该数据库,并且没有新的条目。此外,我已尝试以数据库中已存在的任何用户身份登录,但它也无法正常工作。
Rivition2
我还在其他课程的很多的地方将mysql_real_escape_string更改为mysqli_real_escape_string。这会对它产生什么影响,还是基本上做同样的事情?
- 谢谢你 -