Re: [PHP-LANG] database connection question

[email protected] (Derick Rethans) Sun, 29 Dec 2002 12:09:17 +0100 (CET)
Newsgroups php.lang
Message-ID <[email protected]>
Hello,

please forward user questions to the [email protected]
mailinglist, this list is for development _OF_ PHP, not development
_with_ PHP.

Derick


On Sat, 28 Dec 2002, Edmund Yap wrote:

> 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;
> 
> }
> ?>
> 
> 
> 
> 
> -- 
> PHP Language Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 

-------------------------------------------------------------------------
 Derick Rethans                                 http://derickrethans.nl/ 
 PHP Magazine - PHP Magazine for Professionals       http://php-mag.net/
-------------------------------------------------------------------------