php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59828 Using mysql_connect and mysql_select_db won't work
Submitted: 2011-06-24 05:19 UTC Modified: 2011-09-27 19:21 UTC
From: sathia dot musso at gmail dot com Assigned:
Status: Closed Package: mysqlnd_ms (PECL)
PHP Version: 5.3.6 OS: debian lenny
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.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sathia dot musso at gmail dot com
New email:
PHP Version: OS:

 

 [2011-06-24 05:19 UTC] sathia dot musso at gmail dot com
Description:
------------
Hi, I have installed the extension correctly, if I use 
mysqli_connect it will work without problem, if I use 
mysql_connect and then mysql_select_db it won't work, this is 
the mysql_error response:

Commands out of sync; you can't run this command now


Reproduce code:
---------------
$dbhost = "myapp";
$mysql_link = mysql_connect($dbhost, $dbuser, $dbpasswd) or die(mysql_error());
mysql_select_db ($dbname, $mysql_link) or die(mysql_error());
//mysql_select_db ($dbname) or die(mysql_error()); //tried both


Commands out of sync; you can't run this command now


Expected result:
----------------
from the documentation mysql_connect is supported. I can't get 
it to work


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-06-24 07:16 UTC] sathia dot musso at gmail dot com
I've seen that disabling lazy connections mysql_select_db() 
works, 
I'm a bit worried about the over-head that will be generated
 [2011-06-24 07:22 UTC] andrey@php.net
this is a known problem when using lazy_connections. It is valid for all commands that are broadcasted to all servers:
- select_db
- change_user
- set_charset
etc.
 [2011-06-24 07:27 UTC] sathia dot musso at gmail dot com
Do you think that using this extension for a busy site with 
lazy connections disabled could be possible, or would you 
update all the queries in order to use the correct database?

thanks
 [2011-06-24 07:50 UTC] andrey@php.net
We need to guarantee consistency when DB is changed. If you provide the DB, as with mysqli, but not with ext/mysql, at connect time, then lazy will work, as we internally store the connect information. In our current development version we use JSON for the INI file and we can define user,pass,db,etc per server basis, thus one doesn't need to set the DB explicitly with a call.
In any case, we need to find a solution which works with lazy and broadcasted commands.
 [2011-06-24 07:51 UTC] andrey@php.net
We need to guarantee consistency when DB is changed. If you provide the DB, as with mysqli, but not with ext/mysql, at connect time, then lazy will work, as we internally store the connect information. In our current development version we use JSON for the INI file and we can define user,pass,db,etc per server basis, thus one doesn't need to set the DB explicitly with a call.In any case, we need to find a solution which works with lazy and broadcasted commands.
 [2011-08-16 20:21 UTC] nick at ihighteam dot com
I'm having the same problem.  I definitely don't want to disable lazy connections, but I also don't want to refactor a large codebase to use mysqli or some other solution.  One of the big benefits of this extension is the drop-in functionality.
 [2011-09-27 19:16 UTC] ulf dot wendel at phpdoc dot de
This bug has been fixed in SVN.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.

1.1.0-beta release coming soon. Most of the lazy connection limits have been lifted, please, have a look at the documentation preview available at http://docs.php.net/manual/en/mysqlnd-ms.pooling.php .
 [2011-09-27 19:21 UTC] sathia dot musso at gmail dot com
this is awesome news, if any mysqlnd_ms developer wants to 
have some stats on a high traffic site feel free to drop me a 
line
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Jul 05 14:01:39 2020 UTC