Giacomo P. Thu Dec 30 11:14:22 -0500 2010

Subject: Connection parameters

Hi all,
Maybe this is a PHP issue but I need to make the connection string be parametric.
This is how (usually) the connection string works:
$cfg->set_connections(array('development' => 'mysql://username:password@localhost/database_name'));

I would like to have an associative array with connection parameters like this:
$config = array("username"=>"myuname", "passwd"=>"mypwd", ...);

And use it in the connection string in this way:
$cfg->set_connections(array('development' => 'mysql://$config['myuname']:$config['mypwd'] ...));

I know that it won't work with this syntax, this is for simplicity, but the point is that I have the correct string (I can print it correctly) but I get a "connection string empty" error.
Can I make it working or the associative array MUST have a static string as value?

Thanks to all.

alin mircea Thu Dec 30 21:23:41 -0500 2010


"Default connection" is what you should look for on that page.

It`s always easier to find it yourself than wait for an answer


Giacomo P. Fri Dec 31 05:16:28 -0500 2010

This is not what I was looking for but thank you anyway.

Jacques Fuentes Wed Jan 05 20:57:33 -0500 2011

In your example you are using a single quoted string which means PHP isn't doing string interpolation. Please look at this: