[PHP-DB] Weird Problem In mysql_connect();
Hey all I can connect with $conn = mysql_connect(IP_Address,username,password); but I can't connect with $host = IP_Address; $user = username; $pass = password; $conn = mysql_connect($host,$user,$pass); Any ideas? All I get is Can't connect to MySQL Server on 'localhost', which is kinda weird cos I'm actually specifying a (different) IP address in the host argument. I know it wasn't broken, but I decided to try and fix it anyways!!! TIA! Dave
RE: [PHP-DB] Weird Problem In mysql_connect();
yeah - everything's fine! All the variables are being stored, but they're not getting passed to mysql_connect() for some really strange reason! :-( I've done a temporary fix - moved the entire database connection function to a separate file, and required that from the first required file (!), and it's working, but the original problem has still got me confused!!! Dave -Original Message- From: Brunner, Daniel [mailto:[EMAIL PROTECTED]] Sent: 31 August 2001 21:32 To: Dave Watkinson Subject: RE: [PHP-DB] Weird Problem In mysql_connect(); Hello!! Have your tried to echo the $host?? like $host=123.100.321.1 echo $host; Dan -- From: Dave Watkinson Sent: Friday, August 31, 2001 3:17 PM To: PHP-DB List (E-mail) Subject: [PHP-DB] Weird Problem In mysql_connect(); Hey all I can connect with $conn = mysql_connect(IP_Address,username,password); but I can't connect with $host = IP_Address; $user = username; $pass = password; $conn = mysql_connect($host,$user,$pass); Any ideas? All I get is Can't connect to MySQL Server on 'localhost', which is kinda weird cos I'm actually specifying a (different) IP address in the host argument. I know it wasn't broken, but I decided to try and fix it anyways!!! TIA! Dave -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] Weird Problem In mysql_connect();
Yeah I just tried myself and it didn't work... localhost works as hostnameBut no IP number...hm.. Maybe it's the . in the variable...hm. Dan Anybody else have a idea?!!??! -- From: Dave Watkinson Sent: Friday, August 31, 2001 3:25 PM To: PHP-DB List (E-mail) Subject: RE: [PHP-DB] Weird Problem In mysql_connect(); yeah - everything's fine! All the variables are being stored, but they're not getting passed to mysql_connect() for some really strange reason! :-( I've done a temporary fix - moved the entire database connection function to a separate file, and required that from the first required file (!), and it's working, but the original problem has still got me confused!!! Dave -Original Message- From: Brunner, Daniel [mailto:[EMAIL PROTECTED]] Sent: 31 August 2001 21:32 To: Dave Watkinson Subject: RE: [PHP-DB] Weird Problem In mysql_connect(); Hello!! Have your tried to echo the $host?? like $host=123.100.321.1 echo $host; Dan -- From: Dave Watkinson Sent: Friday, August 31, 2001 3:17 PM To: PHP-DB List (E-mail) Subject:[PHP-DB] Weird Problem In mysql_connect(); Hey all I can connect with $conn = mysql_connect(IP_Address,username,password); but I can't connect with $host = IP_Address; $user = username; $pass = password; $conn = mysql_connect($host,$user,$pass); Any ideas? All I get is Can't connect to MySQL Server on 'localhost', which is kinda weird cos I'm actually specifying a (different) IP address in the host argument. I know it wasn't broken, but I decided to try and fix it anyways!!! TIA! Dave -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Weird Problem In mysql_connect();
You mean you had all this inside a function? Like: function dbConnect () { $link = mysql_connect($host,$user,$pass); } ? If so, did you pass $host, $user, and $pass to the function by global-ing them like: function dbConnect () { global $host; global $user; global $pass; $link = mysql_connect($host,$user,$pass); } -OR- function dbConnect ($host,$user,$pass) { $link = mysql_connect($host,$user,$pass); } - Jonathan Dave Watkinson [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... yeah - everything's fine! All the variables are being stored, but they're not getting passed to mysql_connect() for some really strange reason! :-( I've done a temporary fix - moved the entire database connection function to a separate file, and required that from the first required file (!), and it's working, but the original problem has still got me confused!!! Dave -Original Message- From: Brunner, Daniel [mailto:[EMAIL PROTECTED]] Sent: 31 August 2001 21:32 To: Dave Watkinson Subject: RE: [PHP-DB] Weird Problem In mysql_connect(); Hello!! Have your tried to echo the $host?? like $host=123.100.321.1 echo $host; Dan -- From: Dave Watkinson Sent: Friday, August 31, 2001 3:17 PM To: PHP-DB List (E-mail) Subject: [PHP-DB] Weird Problem In mysql_connect(); Hey all I can connect with $conn = mysql_connect(IP_Address,username,password); but I can't connect with $host = IP_Address; $user = username; $pass = password; $conn = mysql_connect($host,$user,$pass); Any ideas? All I get is Can't connect to MySQL Server on 'localhost', which is kinda weird cos I'm actually specifying a (different) IP address in the host argument. I know it wasn't broken, but I decided to try and fix it anyways!!! TIA! Dave -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] Weird Problem In mysql_connect();
err... neither! Originally I had function dbConnect (){ $link = mysql_connect(ipaddress,username,password); } And what I tried to do was require('somefile'); who's contents were: ? $host = ipaddress; $user = username; $pass = password; ? and then edit the function on the first file to show function dbConnect (){ $link = mysql_connect($host,$user,$pass); } When I saw that this wasn't working, I tried to put the three variable at the top of the file and it still wouldn't work. I think Dan's on the case with the IP Address thing ... I'll see what I can do about users and stuff. I'm running Win2K here :-( Cheers Dave -Original Message- From: Jonathan Hilgeman [mailto:[EMAIL PROTECTED]] Sent: 31 August 2001 21:55 To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Weird Problem In mysql_connect(); You mean you had all this inside a function? Like: function dbConnect () { $link = mysql_connect($host,$user,$pass); } ? If so, did you pass $host, $user, and $pass to the function by global-ing them like: function dbConnect () { global $host; global $user; global $pass; $link = mysql_connect($host,$user,$pass); } -OR- function dbConnect ($host,$user,$pass) { $link = mysql_connect($host,$user,$pass); } - Jonathan Dave Watkinson [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... yeah - everything's fine! All the variables are being stored, but they're not getting passed to mysql_connect() for some really strange reason! :-( I've done a temporary fix - moved the entire database connection function to a separate file, and required that from the first required file (!), and it's working, but the original problem has still got me confused!!! Dave -Original Message- From: Brunner, Daniel [mailto:[EMAIL PROTECTED]] Sent: 31 August 2001 21:32 To: Dave Watkinson Subject: RE: [PHP-DB] Weird Problem In mysql_connect(); Hello!! Have your tried to echo the $host?? like $host=123.100.321.1 echo $host; Dan -- From: Dave Watkinson Sent: Friday, August 31, 2001 3:17 PM To: PHP-DB List (E-mail) Subject: [PHP-DB] Weird Problem In mysql_connect(); Hey all I can connect with $conn = mysql_connect(IP_Address,username,password); but I can't connect with $host = IP_Address; $user = username; $pass = password; $conn = mysql_connect($host,$user,$pass); Any ideas? All I get is Can't connect to MySQL Server on 'localhost', which is kinda weird cos I'm actually specifying a (different) IP address in the host argument. I know it wasn't broken, but I decided to try and fix it anyways!!! TIA! Dave -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Weird Problem In mysql_connect();
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 [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]