php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15458 mysql_pconnect return boolean
Submitted: 2002-02-08 17:19 UTC Modified: 2002-02-08 17:53 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: chang at digitalhighway dot net Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 4.1.1 OS: Solaris 8
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: chang at digitalhighway dot net
New email:
PHP Version: OS:

 

 [2002-02-08 17:19 UTC] chang at digitalhighway dot net
$con = mysql_pconnect($db_Hostname, $db_UserName, $db_Password) || die("Can't Connect to Database: ".mysql_error());

print gettype($con);
print $con;

The connection is okay, no error is given. PHP generates an error if the username or password is incorrect. 
Variable $con supposed to be a link, but instead its a boolean with the value true(1). Just for info, other php scripts work fine in conjuction with mysql. but for this script I need to have seperate links, instead of de default last one.

Compile options: --with-mysql

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-08 17:22 UTC] chang at digitalhighway dot net
$con = mysql_connect($db_Hostname, $db_UserName, $db_Password) ||
die("Can't Connect to Database: ".mysql_error());

print gettype($con);
print $con;

The connection is okay, no error is given. PHP generates an error if the
username or password is incorrect. 
Variable $con supposed to be a link, but instead its a boolean with the
value true(1). Just for info, other php scripts work fine in conjuction
with mysql. but for this script I need to have seperate links, instead
of de default last one.

Compile options: --with-mysql

 [2002-02-08 17:24 UTC] chang at digitalhighway dot net
Sorry forgot to mention, platform is Sparc. And the error also applies for mysql_connect.
 [2002-02-08 17:53 UTC] mfischer@php.net
You've been caught by 'Operator Precedence'.

First, the evaluation of the '||' operator is done. Since you can successfully connect (and a resource is a logical true), the statement 'opa || opb' gives 'true' then this is assigned to $con.

For what you want to do, you need to set parenthesis properly:

($con = mysql_pconnect($db_Hostname, $db_UserName, $db_Password) || die("Can't Connect to Database: ".mysql_error());
 [2002-02-08 18:02 UTC] chang at digitalhighway dot net
Thanks for the help and fast reply.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed May 07 19:01:32 2025 UTC