wOne30 Posted January 20, 2010 Share Posted January 20, 2010 Hello Community, I am currently trying to create my own shopping cart system. Here is the code I have so far: <?php /** * connects to database server and selects database * @return bool */ function db_connect() { $connection = mysql_pconnect('localhost','myusername','mypass'); if(!$connection) { return false; } if(!mysql_select_db('amgarden_catalog')) { return false; } return $connection; } /** * Turns MYSQL resource into array * @param resource $result * @return array */ function db_result_to_array($result) { $res_array = array(); for ($count=0; $row = mysql_fetch_array($result); $count++) { $res_array[$count] = $row; } return $res_array; } /** * finds products and lists them in DESC order * @return array */ function find_products() { db_connect(); $query = "SELECT * FROM products order by products.id DESC"; $result = mysql_query($query); $result = db_result_to_array($result); return $result; } /** * finds one product by id * @return array */ function find_products($id) { db_connect(); $query = sprintf("SELECT * FROM products WHERE products.id = '%s'", mysql_real_escape_string($id)); $result = mysql_query($query); $row = mysql_fetch_array($result); return $row; } $product = find_product(); echo $product['title'].'<br/>'; ?> I know that is something dumb that I am missing but I am at my wits end trying to figure it out today. Here is the error I continue to get: Fatal error: Cannot redeclare find_products() (previously declared in /home/public_html/products/db_fns.php:53) in /home/public_html/products/db_fns.php on line 81 Quote Link to comment Share on other sites More sharing options...
ignace Posted January 20, 2010 Share Posted January 20, 2010 The error says it all. You can't redeclare the function find_products() because it is already defined in db_fns.php on line 53 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.