Re: Weird Problem In mysql_connect();
| From: | Chris Hobbs | Date: | Fri, 31 Aug 2001 22:52:25 +0000 |
| Subject: | Re: Weird Problem In mysql_connect(); | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-12068@lists.php.net to get a copy of this message | ||
JH has it right - your function has no idea what $host, $user, and $pass are, because they're out of scope. Add the global statements that Jonathan suggested inside your dbConnect function, and all will be well.
Dave Watkinson wrote:
function dbConnect (){ $link = mysql_connect($host,$user,$pass); }And Jonathan Hilgeman correctly recommended:
function dbConnect () { global $host; global $user; global $pass; $link = mysql_connect($host,$user,$pass); }-- _______ ___ _ ____ _____ Chris Hobbs / ____\ \ / / | | |/ ___\| __ \ Head Geek | (___ \ \ / /| | | | (___ | | | | WebMaster \___ \ \ \/ / | | | |\___ \| | | | PostMaster ____) | \ / | |__| |____) | |__| | \____/ \/ \____/ \____/|_____/ http://www.silvervalley.k12.ca.us chobbs@silvervalley.k12.ca.us