Bluehost.com Web Hosting $6.95

Re: [PHP] Weird problem when creating a db connection and tryingto reference it in a function

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: > &...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-25-2003
Burhan Khalid
 
Posts: n/a
Default Re: [PHP] Weird problem when creating a db connection and tryingto reference it in a function

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
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 04:36 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0