database connection question

From: Date: Fri, 27 Dec 2002 18:28:43 +0000
Subject: database connection question
Groups: php.lang 
Request: Send a blank email to php-lang+get-430@lists.php.net to get a copy of this message
Hi, a function display_categories() in display.php tries to connect to a database with the function db_connect() residing in db_connections.php. However, this results in the error "mysql_query(): supplied argument is not a valid MySQL-Link resource ". I still can't figure out the error in my code. Can someone enlighten me? Thanks! Best Regards, Edmund Yap *********** display.php: ************ <? include ("db_connections.php"); function display_categories() { db_connect(); echo $mysql_link; $query = "select * from ProductCategory order by ProductCategoryName"; // mysql_query(): supplied argument is not a valid MySQL-Link resource... $mysql_result = mysql_query($query, $mysql_link); // mysql_fetch_row(): supplied argument is not a valid MySQL result resource in... while($row = mysql_fetch_row($mysql_result)) { //blar blar blar } } ?> ******************** db_connections.php: ******************** <? function db_connect() { $mysql_link = mysql_pconnect("localhost", "username", "password"); if (!$mysql_link) return false; if (!mysql_select_db(("products"), $mysql_link)) return false; return $mysql_link; } ?>

« previous php.lang (#430) next »