The answer to the interpolation problem is to use double quotes:
$dsn =
"{$servers["$id"]["type"]}://{$servers["$id"]["username"]}:{$servers["$id"]["password"]}@{$servers["$id"]["hostName"]}/{$servers["$id"]["databaseName"]}";
John Ellingsworth wrote:
Hi.
I am sure there is an easy answer to this, but I do not know it and have
not found the answer anywhere. I want to be able to dynamically set my
database from an array of options:
$database = array(
array(
"type" => "mssql",
"name" => "database1",
"hostName" => "hostname1",
"username" => "username1",
"password" => "password1",
"databaseName" => "database1"),
array(
"type" => "mssql",
"name" => "database2",
"hostName" => "hostname2",
"username" => "username2",
"password" => "password2",
"databaseName" => "database2"),
);
// default database
$id = 0;
I am trying to use this line using PEAR DB, but the variable does not
get interpreted so it never works (the line wraps; it is not the line
wrapping):
$dsn =
"{$servers[$id]["type"]}://{$servers[$id]["username"]}:{$servers[$id]["password"]}@{$servers[$id]["hostName"]}/{$servers[$id]["databaseName"]}";
This works, so the problem is translating $id properly:
$dsn =
"{$servers[0]["type"]}://{$servers[0]["username"]}:{$servers[0]["password"]}@{$servers[0]["hostName"]}/{$servers[0]["databaseName"]}";
I would appreciate any help with this.
--
Thanks,
John Ellingsworth
Project Leader, Virtual Curriculum
Academic Programs
School of Medicine
University of Pennsylvania
(215) 573-4451
Virtual Curriculum
http://www.cu2000.med.upenn.edu
AIM: vc2000support
To contact the Virtual Curriculum team:
cu2000@xxxxxxxxxxxxxxxxxx
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php