Доброй ночи, поздравляю всех с новым 2014 годом!
Я уже не один раз задавал вопросы о проекте, который мне доверили -
тут,
тут,
тут и вот
здесь.
Обрисую проблему - когда заходим на
login.php или на страницу регистрации, то видим одинаковые предупреждения:
Warning: mysqli_fetch_row() expects parameter 1 to be mysqli_result, boolean given in /var/www/GameEngine/Database/db_MYSQLi.php on line 2834
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /var/www/GameEngine/Automation.php on line 905
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /var/www/GameEngine/Automation.php on line 4006
Warning: Invalid argument supplied for foreach() in /var/www/GameEngine/Automation.php on line 4196
Warning: Invalid argument supplied for foreach() in /var/www/GameEngine/Automation.php on line 1042
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /var/www/GameEngine/Automation.php on line 4006
Но если попытаться зайти в игру, то увидим такие ошибки:
Warning: mysqli_fetch_row() expects parameter 1 to be mysqli_result, boolean given in /var/www/GameEngine/Database/db_MYSQLi.php on line 2834
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /var/www/GameEngine/Automation.php on line 905
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /var/www/GameEngine/Automation.php on line 4006
Warning: Invalid argument supplied for foreach() in /var/www/GameEngine/Automation.php on line 4196
Warning: Invalid argument supplied for foreach() in /var/www/GameEngine/Automation.php on line 1042
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /var/www/GameEngine/Automation.php on line 4006
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /var/www/GameEngine/Database/db_MYSQLi.php on line 76
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /var/www/GameEngine/Database/db_MYSQLi.php on line 206
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /var/www/GameEngine/Database/db_MYSQLi.php on line 225
Connect Error (0)
Вот так начинается код класса:
class MYSQLi_DB {
var $connection;
function MYSQL_DB() {
$this->connection = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS, SQL_DB) or die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
}
Вот кусок кода, где происходит ошибка
Connect Error (0):
function sitterLogin($username, $password) {
$q = "SELECT sit1,sit2 FROM " . TB_PREFIX . "users WHERE username = '$username' AND access != " . BANNED;
$result = mysqli_query($this->connection, $q);
$dbarray = mysqli_fetch_array($result, MYSQLI_BOTH); //ОШИБКА ЗДЕСЬ
if($dbarray['sit1'] != 0) {
$q2 = "SELECT password FROM " . TB_PREFIX . "users WHERE id = " . $dbarray['sit1'] . " AND access != " . BANNED;
$result2 = mysqli_query($this->connection, $q2);
$dbarray2 = mysqli_fetch_array($result2, MYSQLI_BOTH);
}
if($dbarray['sit2'] != 0) {
$q3 = "SELECT password FROM " . TB_PREFIX . "users WHERE id = " . $dbarray['sit2'] . " AND access != " . BANNED;
$result3 = mysqli_query($this->connection, $q3);
$dbarray3 = mysqli_fetch_array($result3, MYSQLI_BOTH);
}
if($dbarray['sit1'] != 0 || $dbarray['sit2'] != 0) {
if($dbarray2['password'] == md5($password) || $dbarray3['password'] == md5($password)) {
return true;
} else {
return false;
}
} else {
return false;
}
}
Как улучшить код? Как избавиться от предупреждений?