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:
localhost
myUser
myPass
myDB
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
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:
localhost
myUser
myPass
myDB
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
Comment