#29391 [Opn->Bgs]: cannot connect to MySQL from the web server

From: Date: Mon, 26 Jul 2004 16:40:49 +0000
Subject: #29391 [Opn->Bgs]: cannot connect to MySQL from the web server
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-63574@lists.php.net to get a copy of this message
ID: 29391 Updated by: georg@php.net Reported By: chcaron at nrcan dot gc dot ca -Status: Open +Status: Bogus Bug Type: iPlanet related Operating System: Soalris 2.8 PHP Version: 4.3.8 New Comment: How about to remove the warning suppress in mysql_connect to see what failed? Previous Comments: ------------------------------------------------------------------------ [2004-07-26 17:40:02] chcaron at nrcan dot gc dot ca Description: ------------ PHP has been installed with "with-mysql=/usr/local/mysql". PHP 4.3.8 Mysql 4.0.15 iPlanet 6.1 It was working well with PHP 4.3.4 before we upgrade. Once we upgraded PHP to 4.3.8, we got "mysql_connect(): Can't connect to MySQL server..." when trying to open a page from the webserver. The command-line PHP was still working correctly. We recompiled PHP with "with-mysql" only (built-in MySQL) and it all started working ok. Reproduce code: --------------- <html> <body> <?php $hostname = 'hostname'; $user = 'root'; $passwd = 'password'; $database_name = 'mysql'; $error_connection = 'Cannot connect to MySQL'; $error_db = "Invalid database name ($database_name)"; if (!($connection = @ mysql_connect($hostname, $user, $passwd))) die("$error_connection"); if (!(mysql_select_db($database_name, $connection))) die("$error_db"); $query = "show tables;"; if (!($result = mysql_query ($query, $connection))) die("error"); while ($row = @ mysql_fetch_array($result)) { echo "$row[0]<br>"; } ?> </body> </html> Expected result: ---------------- The list of tables should print on the screen if ran from the webserver: columns_priv db func host tables_priv user If ran from the command line: nrn1# /usr/local/php/bin/php test_PHP_mysql.php <html> <body> columns_priv<br>db<br>func<br>host<br>tables_priv<br>user<br></body> </html> nrn1# Actual result: -------------- From the webserver: Cannot connect to MySQL From the command line: nrn1# /usr/local/php/bin/php test_PHP_mysql.php <html> <body> columns_priv<br>db<br>func<br>host<br>tables_priv<br>user<br></body> </html> nrn1# ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=29391&edit=1

« previous php.bugs (#63574) next »