Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\catalog\function.php on line 15
Что я не так делаю?
файл config:
<?php
define("DBHOST", "localhost");
define("DBUSER", "root");
define("DBPASS", "123");
define("DB", "apple");
$connection = @mysqli_connect(DBHOST, DBUSER, DBPASS, DB) or die("Нет соединения с БД");
mysqli_set_charset($connection, "utf8") or die("Не установлена кодировка соединения");
?>
файл function:
<?php
function db_result_to_array($result)
{
$res_array = array();
$count = 0;
while($row = mysql_fetch_array($result))
{
$res_array[$count] = $row;
$count++;
}
return $res_array;
}
function get_products()
{
global $connection;
$query = "SELECT * FROM products ORDER BY id DESC";
$result = mysql_query($query);
$result = db_result_to_array($result);
return $result;
}
?>