Hello. I connect DB using the code:
<? function db_connect() { $host = 'localhost'; $user = 'shop_user'; $pswd = 'admin123'; $db = 'shop'; $connection = mysql_connect($host, $user, $pswd); if (!$connection || !mysql_select_db($db, $connection)) { return false; } return $connection; } function db_result_to_array() { $res_array = array(); $count = 0; while ($row = mysql_fetch_array($result)) { $res_array[$count] = $row; $count++; } return $res_array; } function get_products() { db_connect(); $query = "SELECT * FROM products ORDER BY id DESC"; $result = mysql_query($query); $result = db_result_to_array($result); return $result; } ?>
It produces the following error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\appserver\www\shop\db_fns.php on line 25
Help, please, what needs to be fixed?