Dynamic vars not the same ?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
My Dynamic variables print out, same as strings but aren't the same.
They are not correct when using them as DB.connection vars.

I was using my own routine, that read in string values from a config
file, that had entries like    host=localhost   etc, etc.
After reading, I used explode with "=" as a separator,... then finally
created some dynamic vars     $$key=$val

They are valid, it seems and printout/echo correct normal values:
They look the same as quoted strings, but when used as database
connection parameters, fail to create a connection.

$link = new mysqli( $host, $user, $pass, $db );  // fails

$link = new mysqli( "localhost", "myUser", "myPass", "myDB" ); // works
and creates a connection

Anyone know why ?  Maybe I'm missing something simple.
I'm also exploring good alternatives for config file read-in.  THX

Re: Dynamic vars not the same ?

It appears that php added a space onto the end of the string, or
perhaps it was a \r\n sequence of characters.  Regardless,  trim()
took care of the problem.

Site Timeline