I get this error when running this code Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource. The code isI read around and someone said this is because the code isnt linking properly to the DB. However if I doCode:<?php function fetch_products(){ $sql = "SELECT 'product_id','product_name' FROM 'products'"; $result = mysql_query($sql); $products = array(); while(($row = mysql_fetch_assoc($result)) !== false){ $products[$row['product_id']] = $row['product_name']; } return $products; } ?>Code:<?php function fetch_products(){ $result = mysql_query("SELECT * FROM products"); $products = array(); while(($row = mysql_fetch_assoc($result)) !== false){ $products[$row['product_id']] = $row['product_name']; } return $products; } ?>


Reply With Quote
Bookmarks