php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13715 Cannot open 'multiple' database connections while running from shell
Submitted: 2001-10-17 13:42 UTC Modified: 2001-11-20 19:51 UTC
From: chuckc at sonic dot net Assigned:
Status: Closed Package: MySQL related
PHP Version: 4.0.5 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: chuckc at sonic dot net
New email:
PHP Version: OS:

 

 [2001-10-17 13:42 UTC] chuckc at sonic dot net
I'm trying to open multiple database connections to a 'non-local' mysql server from the shell.

It is important to note that this problem only occurs while running from the shell.  When running the same code from the web server, there is no problem.

#!/usr/bin/php 
<?php

//connect to database 1
$link_a = mysql_connect ("server", "uname1", "pword1")
    or die ("Could not connect to db1\n");
print ("Connected to db1 successfully\n");

//connect to database 2
$link_b = mysql_connect ("server", "uname2", "pword2")
    or die ("Could not connect to db2\n");
print ("Connected to db2 successfully\n");

?>

It does not matter which database you try to connect to first.  Regardless, the first connection succeeds, the second connection fails.


Some output:
Connected to domains successfully
<br>
<b>Warning</b>:  MySQL Connection Failed: Can't connect to MySQL server on spiff (111)
 in <b>./qtest.php</b> on line <b>23</b><br>
Could not connect to users db


I compiled PHP like so:
./configure --with-mysql=/opt/mysql --with-gd --prefix=/opt/php-4.0.5 --sysconfdir=/opt/php-4.0.5/etc --with-zlib-dir=/usr/local/ --
with-dom=/usr/local/lib/libxml12.so --with-mcrypt=/usr/local/lib/libmcrypt.so --with-cybercash=/opt/mck-3.2.0.4-linux --enable-force
-cgi-redirect

Thanks,
chuckc@sonic.net

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-20 12:52 UTC] mfischer@php.net
Please try the latest RC and see if the problem persists:

http://www.php.net/~zeev/php-4.1.0RC3.tar.gz

Feedback.
 [2001-11-20 13:38 UTC] chuckc at sonic dot net
Upgraded to 4.1.0RC3.  Did not fix the problem or change any of the symptoms.

The Install was very smooth though :)

Chuckc
 [2001-11-20 19:51 UTC] mfischer@php.net
Mosty likely a problem with the mysql socket as now TCP connections work.

Closing.

User Feedback:
---------------- 
Hi again,

With your help, I think the problem is solved!!

I changed my connection call to include the 'mysql server port' and the
problem went away.

Instead of:
$link = mysql_connect("server", "username", "password")

I put:
$link = mysql_connect("server:3306", "username", "password")

I did this for both connection calls and it started working.  Very strange
though.  The first connection was made on the default port of 3306 but the
second connection was not.  On systems with running only one MySql server,
this does not seem to be a problem.  However, on systems like mine with
multiple servers running, the second connection was not made to the default
port.  Hmmm.

Well, mystery solved....kind of.  All is working now though.  Should I do
anything to document this?  Please let me know.

Thanks for your help,
Chuckc


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 01 23:01:28 2024 UTC