Re: [PHP] Is this a mysql_connect() bug?

2005-01-30 Thread tom soyer
Thanks everyone for all the help. I found the problem. It has to do
with a bug in my error handler class that my script loaded prior to
executing mysql_connect(). Once I removed  the error handler class,
mysql_connect() started to behave as expected. My bad.

Tom


On Sun, 30 Jan 2005 01:16:10 -0600, Michael Sims
[EMAIL PROTECTED] wrote:
 tom soyer wrote:
  Thanks for the error handling code. I think PHP still has a basic
  problem. If mysql sever connection times out because wrong username or
  password was used, then mysql_connect() should return FALSE.
 
 It does, at least for me on PHP 4.3.10 connecting to a local MySQL 4.0.23
 server on Debian.  It returns a boolean false, and a warning is triggered:
 
 Warning: mysql_connect(): Access denied for user: '[EMAIL PROTECTED]' (Using
 password: YES) in ...
 
 If I give it a server name it cannot connect to (due to a firewall blocking
 the connection, for example) it will hang for about 60 seconds then return
 false, triggering a warning:
 
 Warning: mysql_connect(): Can't connect to MySQL server on ...
 
 I was going to suggest that you run a cli test script and trace the system
 calls to see what's going on but then I saw that you're using Windows.  I'm
 not sure if there is an strace/truss equivalent for it (anyone know)?
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



[PHP] Is this a mysql_connect() bug?

2005-01-29 Thread tom soyer
Hi,

I tried mysql_connect() function, and it won't reture FALSE if
connection failed. Instead, the script times out after 30 seconds and
displays an Fatal error message Maximum execution time of 30 seconds
exceeded. For example:

mysql_connect(' ',' '); returns TRUE because mysql logs in the user as
guest. But mysql_connect('servername','username','wrongpassword');
does not return FALSE. Instead, the script continues until it times
out. Does anyone know if this is a known bug, or can this be fixed by
changing a diretive/setting that I don't know about?

thanks,

Tom

P.S., I am using PHP 4.3.10, Apache 2.0.52(win 32), MSIE 6.0, Mysql
4.0.23-nt, Windows NT 5.1 (XP)

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



Re: [PHP] Is this a mysql_connect() bug?

2005-01-29 Thread trlists
On 29 Jan 2005 tom soyer wrote:

 I tried mysql_connect() function, and it won't reture FALSE if
 connection failed. Instead, the script times out after 30 seconds and
 displays an Fatal error message Maximum execution time of 30 seconds
 exceeded. 

I think the issue here is if the server does not respond it hits the 
execution time limit before the function returns.

I use code like this:

$olderr = error_reporting(0);
set_error_handler('ignoreerrhandler');
$dbHandle = mysql_connect($dbHost, $dbUser, $pw);
restore_error_handler();
error_reporting($olderr);

.

function ignoreerrhandler($errno, $errstr, $errfile, $errline) {
return;
}

You can also control the connection timeout with the 
mysql.connect_timeout setting in php.ini.

--
Tom

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



Re: [PHP] Is this a mysql_connect() bug?

2005-01-29 Thread tom soyer
Thanks for the error handling code. I think PHP still has a basic
problem. If mysql sever connection times out because wrong username or
password was used, then mysql_connect() should return FALSE. But this
is not the case, why? Is it possible that mysql_connect() could not
read the connection failed message from mysql server?


On Sat, 29 Jan 2005 23:01:46 -0500, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 On 29 Jan 2005 tom soyer wrote:
 
  I tried mysql_connect() function, and it won't reture FALSE if
  connection failed. Instead, the script times out after 30 seconds and
  displays an Fatal error message Maximum execution time of 30 seconds
  exceeded.
 
 I think the issue here is if the server does not respond it hits the
 execution time limit before the function returns.
 
 I use code like this:
 
$olderr = error_reporting(0);
set_error_handler('ignoreerrhandler');
$dbHandle = mysql_connect($dbHost, $dbUser, $pw);
restore_error_handler();
error_reporting($olderr);
 
.
 
function ignoreerrhandler($errno, $errstr, $errfile, $errline) {
return;
}
 
 You can also control the connection timeout with the
 mysql.connect_timeout setting in php.ini.
 
 --
 Tom
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



RE: [PHP] Is this a mysql_connect() bug?

2005-01-29 Thread Michael Sims
tom soyer wrote:
 Thanks for the error handling code. I think PHP still has a basic
 problem. If mysql sever connection times out because wrong username or
 password was used, then mysql_connect() should return FALSE.

It does, at least for me on PHP 4.3.10 connecting to a local MySQL 4.0.23
server on Debian.  It returns a boolean false, and a warning is triggered:

Warning: mysql_connect(): Access denied for user: '[EMAIL PROTECTED]' (Using
password: YES) in ...

If I give it a server name it cannot connect to (due to a firewall blocking
the connection, for example) it will hang for about 60 seconds then return
false, triggering a warning:

Warning: mysql_connect(): Can't connect to MySQL server on ...

I was going to suggest that you run a cli test script and trace the system
calls to see what's going on but then I saw that you're using Windows.  I'm
not sure if there is an strace/truss equivalent for it (anyone know)?

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



Re: [PHP] Is this a mysql_connect() bug?

2005-01-29 Thread Burhan Khalid
tom soyer wrote:
Thanks for the error handling code. I think PHP still has a basic
problem. If mysql sever connection times out because wrong username or
password was used, then mysql_connect() should return FALSE. But this
is not the case, why? Is it possible that mysql_connect() could not
read the connection failed message from mysql server?
I don't think this is case, because I thought that the problem could be 
that the script is timing out before MySQL can return a status code 
(possibly because MySQL is busy; network congestion, etc.)

However, after reading this:
Note: The set_time_limit() function and the configuration directive 
max_execution_time only affect the execution time of the script itself. 
Any time spent on activity that happens outside the execution of the 
script such as system calls using system(), stream operations, database 
queries, etc. is not included when determining the maximum time that the 
script has been running.

I think the problem is not the script timing out, but rather it could be 
this:

Note: Whenever you specify localhost or localhost:port as server, 
the MySQL client library will override this and try to connect to a 
local socket (named pipe on Windows). If you want to use TCP/IP, use 
127.0.0.1 instead of localhost. If the MySQL client library tries to 
connect to the wrong local socket, you should set the correct path as 
mysql.default_host in your PHP configuration and leave the server field 
blank.

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