This is a discussion on Re: [PHP] Weird problem when creating a db connection and tryingto reference it in a function within the PHP General forums, part of the PHP Programming Forums category; Matt Babineau wrote: > I found another strange problem. I am creating a mysql database > connection like this: > &...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |