mysql_pconnect cannot create two permanent connections to the same machine ?

mysql_pconnect cannot create two permanent connections to the same machine ?

am 17.01.2006 16:57:34 von as

--Apple-Mail-2-292464172
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
delsp=yes;
format=flowed

Hi List,

I do not claim that this is bug, but it is not a nice feature either.

I do have following:

/* db.php */
$db_server="127.0.0.1";
$db_user = ******
$db_pass = ******
$db_db = "bebbicell";

$db_account_server="127.0.0.1";
$db_account_user = ********
$db_account_pass = ********
$db_account_db = "asterisk";

//$level= error_reporting ( 0);
$bid=mysql_pconnect($db_server,$db_user,$db_pass);
//error_reporting ( $level);
mysql_select_db($db_db,$bid);

//$level= error_reporting ( 0);
$accid=mysql_pconnect($db_account_server,$db_account_user,
$db_account_pass);
//error_reporting ( $level);
mysql_select_db($db_account_db, $accid);
?>

Note that databases here are totally unrelated. They are on the same
machine only
because i am developing. I want later to move 'asterisk' to a
separate machine, but
when i do this, i want just change $db*s, not any other code. Because
on this, i want
both $bid and $accid to be valid handles.

Currently it is not so. Both

$res = mysql_query($sql,$accid);
$err = mysql_error($accid);

will generate error

Warning: mysql_query(): supplied argument is not a valid MySQL-Link
resource in /var/www/bebbicell.ch/signup.php

And yes, there are no functions in signup.php.

Aarno
--Apple-Mail-2-292464172--

Re: mysql_pconnect cannot create two permanent connections

am 17.01.2006 17:31:33 von Philip Hallstrom

> Hi List,
>
> I do not claim that this is bug, but it is not a nice feature either.
>
> I do have following:
>
> > /* db.php */
> $db_server="127.0.0.1";
> $db_user = ******
> $db_pass = ******
> $db_db = "bebbicell";
>
> $db_account_server="127.0.0.1";
> $db_account_user = ********
> $db_account_pass = ********
> $db_account_db = "asterisk";
>
> //$level= error_reporting ( 0);
> $bid=mysql_pconnect($db_server,$db_user,$db_pass);
> //error_reporting ( $level);
> mysql_select_db($db_db,$bid);
>
> //$level= error_reporting ( 0);
> $accid=mysql_pconnect($db_account_server,$db_account_user,$d b_account_pass);
> //error_reporting ( $level);
> mysql_select_db($db_account_db, $accid);
> ?>
>
> Note that databases here are totally unrelated. They are on the same
> machine only because i am developing. I want later to move 'asterisk' to
> a separate machine, but when i do this, i want just change $db*s, not
> any other code. Because on this, i want both $bid and $accid to be valid
> handles.
>
> Currently it is not so. Both
>
> $res = mysql_query($sql,$accid);
> $err = mysql_error($accid);
>
> will generate error
>
> Warning: mysql_query(): supplied argument is not a valid MySQL-Link
> resource in /var/www/bebbicell.ch/signup.php

Hmm... from the manual:

First, when connecting, the function would first try to find a
(persistent) link that's already open with the same host, username and
password. If one is found, an identifier for it will be returned instead
of opening a new connection.

That is, the database is not considered in determining a pre-existing
persistent connection.

So, if $db_user == $db_account_user and $db_pass == $db_account_pass
then $bid == $accid.

That said though what you have above should work since multiple calls to
mysql_pconnect with the same parameters should just return the original
handle.

Perhaps (and assuming the connection info is identical) $db_user doesn't
have access to $db_account_db to run whatever $sql query you're running?

That error doesn't seem right for that, but that's the only thing I can
think of.

-philip

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: mysql_pconnect cannot create two permanent connections to the same machine ?

am 17.01.2006 18:48:26 von Micah Stevens

On Tuesday 17 January 2006 7:57 am, Aarno Syvänen wrote:
> Hi List,
>
> I do not claim that this is bug, but it is not a nice feature either.
>
> I do have following:
>
> > /* db.php */
> $db_server=3D"127.0.0.1";
> $db_user =3D ******
> $db_pass =3D ******
> $db_db =3D "bebbicell";
>
> $db_account_server=3D"127.0.0.1";
> $db_account_user =3D ********
> $db_account_pass =3D ********
> $db_account_db =3D "asterisk";
>
> //$level=3D error_reporting ( 0);
> $bid=3Dmysql_pconnect($db_server,$db_user,$db_pass);
> //error_reporting ( $level);
> mysql_select_db($db_db,$bid);
>
> //$level=3D error_reporting ( 0);
> $accid=3Dmysql_pconnect($db_account_server,$db_account_user,
> $db_account_pass);
> //error_reporting ( $level);
> mysql_select_db($db_account_db, $accid);
> ?>
>
> Note that databases here are totally unrelated. They are on the same
> machine only
> because i am developing. I want later to move 'asterisk' to a
> separate machine, but
> when i do this, i want just change $db*s, not any other code. Because
> on this, i want
> both $bid and $accid to be valid handles.
>
> Currently it is not so. Both
>
> $res =3D mysql_query($sql,$accid);
> $err =3D mysql_error($accid);
>
> will generate error
>
> Warning: mysql_query(): supplied argument is not a valid MySQL-Link
> resource in /var/www/bebbicell.ch/signup.php
>
> And yes, there are no functions in signup.php.
>
> Aarno

If you remove the $bid connection code, (comment it out) does your test cod=
e=20
with $accid work?=20

=2DMicah=20

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: mysql_pconnect cannot create two permanent connections to the same machine ?

am 18.01.2006 09:56:20 von as

The code worked perfectly when databases 'bebbicell' and 'asterisk' =20
were in the
separate machines. It stopped working, when i copied the website to =20
my machine.

Aarno

On 17 Jan 2006, at 18:48, Micah Stevens wrote:

> On Tuesday 17 January 2006 7:57 am, Aarno Syvänen wrote:
>> Hi List,
>>
>> I do not claim that this is bug, but it is not a nice feature either.
>>
>> I do have following:
>>
>> >> /* db.php */
>> $db_server=3D"127.0.0.1";
>> $db_user =3D ******
>> $db_pass =3D ******
>> $db_db =3D "bebbicell";
>>
>> $db_account_server=3D"127.0.0.1";
>> $db_account_user =3D ********
>> $db_account_pass =3D ********
>> $db_account_db =3D "asterisk";
>>
>> //$level=3D error_reporting ( 0);
>> $bid=3Dmysql_pconnect($db_server,$db_user,$db_pass);
>> //error_reporting ( $level);
>> mysql_select_db($db_db,$bid);
>>
>> //$level=3D error_reporting ( 0);
>> $accid=3Dmysql_pconnect($db_account_server,$db_account_user,
>> $db_account_pass);
>> //error_reporting ( $level);
>> mysql_select_db($db_account_db, $accid);
>> ?>
>>
>> Note that databases here are totally unrelated. They are on the same
>> machine only
>> because i am developing. I want later to move 'asterisk' to a
>> separate machine, but
>> when i do this, i want just change $db*s, not any other code. Because
>> on this, i want
>> both $bid and $accid to be valid handles.
>>
>> Currently it is not so. Both
>>
>> $res =3D mysql_query($sql,$accid);
>> $err =3D mysql_error($accid);
>>
>> will generate error
>>
>> Warning: mysql_query(): supplied argument is not a valid MySQL-Link
>> resource in /var/www/bebbicell.ch/signup.php
>>
>> And yes, there are no functions in signup.php.
>>
>> Aarno
>
> If you remove the $bid connection code, (comment it out) does your =20
> test code
> with $accid work?
>
> -Micah
>
> --=20
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php