Re: Weird problem when creating a db connection and trying to reference it in a function

From: Date: Sat, 25 Oct 2003 03:08:17 +0000
Subject: Re: Weird problem when creating a db connection and trying to reference it in a function
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-167516@lists.php.net to get a copy of this message
Matt Babineau wrote:
I found another strange problem. I am creating a mysql database connection like this: @ $db = mysql_pconnect(host, user, pass); mysql_select_db(dbname);
you forgot the $ ... should be mysql_select_db($dbname); If you had turned up your php error reporting level (error_reporting(E_ALL); for example) it whould have given you a notice about undeclared constant for that line. A php-aware syntax highlighting editor would have also given you a visual cue about the possible "error" on that mysql_select_db() line. Also, I don't see where you are setting $dbname to something. You might have just not included it in your excerpt, but it may also be missing from your script :)
Now, I have a function that inside uses mysql_list_fields() function getFields($table, $dbname) { $fields = mysql_list_fields($dbname, $table); return $fields; }
you can just do this return mysql_list_fields($dbname, $table); -- Burhan Khalid phplist[at]meidomus[dot]com http://www.meidomus.com

« previous php.general (#167516) next »