#43947 [Opn->Bgs]: mysql_select_db fails to select database using variables

From: Date: Mon, 10 Mar 2008 20:14:54 +0000
Subject: #43947 [Opn->Bgs]: mysql_select_db fails to select database using variables
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-123154@lists.php.net to get a copy of this message
ID: 43947 User updated by: joel dot a dot villarreal at gmail dot com Reported By: joel dot a dot villarreal at gmail dot com -Status: Open +Status: Bogus Bug Type: MySQL related Operating System: Windows XP Service Pack 2 PHP Version: 5.2.5 New Comment: Thanks for your assistance. Previous Comments: ------------------------------------------------------------------------ [2008-03-10 20:14:01] joel dot a dot villarreal at gmail dot com I reckon, Will. I've tried the code and now it works. I had to reinstall several system components to make it work properly. My apologies. I'm switching status to bogus. Regards, Joel A. Villarreal Bertoldi. ------------------------------------------------------------------------ [2008-03-10 19:27:54] will dot fitch at gmail dot com I can't reproduce this. Here is my code: connection.cfg.php <? $MySQL_DatabaseName = "mysql"; ?> test.php <? include("connection.cfg.php"); connect(); function connect() { global $MySQL_DatabaseName; mysql_connect("localhost", "root", "########"); mysql_select_db($MySQL_DatabaseName); $row = mysql_fetch_array(mysql_query("SELECT * FROM user"), MYSQL_ASSOC) or die(mysql_error()); print_r($row); } ?> It prints out exactly as expected. I am using PHP 5.2.5 on RHEL5. ------------------------------------------------------------------------ [2008-01-29 17:28:34] joel dot a dot villarreal at gmail dot com I've executed: echo $MySQL_DatabaseName . PHP_EOL; After calling to connect() and it prints out "foo", the value of $MySQL_DatabaseName. ------------------------------------------------------------------------ [2008-01-29 00:33:45] davidc@php.net What do you get if you do: echo $MySQL_DatabaseName . PHP_EOL; right after your connect() ? ------------------------------------------------------------------------ [2008-01-27 22:40:01] joel dot a dot villarreal at gmail dot com Just in case, these are the versions of the server components being used at the moment: PHP Version 5.2.5 MySQL 5.0.46 Apaache 2.2.6 ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/43947 -- Edit this bug report at http://bugs.php.net/?id=43947&edit=1

« previous php.bugs (#123154) next »