Dynamic vars not the same ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • webguynow

    Dynamic vars not the same ?

    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

  • webguynow

    #2
    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.

    Comment

    Working...