tags:

views:

67

answers:

3

Any idea why the following code is not working

mysql credentials are correct, have verified from command line.

The second connection fails i.e., $conn1 . I am clueless !!!

$conn = mysql_connect($hostname,
$username, $password) 
    or die("Connecting to MySQL failed" . mysql_error());

$conn1 = mysql_connect($hostname,
$username1, $password1) 
    or die("Connecting to MySQL failed" . mysql_error());
+1  A: 

It's a guess, but is the second connection supposed to be to $hostname, or perhaps $hostname1 instead.

Tom Dignan
+4  A: 

Test it with hardcoded values first to be sure...

//Connect to database from here
$link = mysql_connect("localhost", "dbaadmin", "sqlpassword");
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
Vijay
+1  A: 

have verified from command line.

There's so many questions here that you have not answered.

The command line where the PHP script is running?

The same chroot environment where the PHP script is running?

The OS user (not database user) is the same as the webserver runs as?

The hostname you are connecting to is on a seperate machine from where the PHP script (and the CLI) is running? (localhost will use a unix domain socket rather than a network socket)

...and just what is the error message you get?

C.

symcbean