database connection question
[email protected] ("Edmund Yap") Sat, 28 Dec 2002 02:28:43 +0800
| Newsgroups | php.lang |
|---|---|
| Message-ID | <[email protected]> |
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;
}
?>