underscore in php db variable causing problems

tonyb

New Member
I store all of my login information for databases in files outside of the public tree in variables such as \[code\]$hostname = '172.0.0.0';$dbname = 'myname_mydbname';$username = 'myname_user';$pw = 'password';\[/code\]That's pretty standard. The problem is that this particular hosting I am working with requires the \[code\]myname_\[/code\] to be appended to the front of all databases and user names. When I store these strings and pass them to a PDO it drops everything in the username after myname, and drops the password string all together... If I put the username and password in the function as strings instead of variables everything works. I am at my wits end. can anyone help? here is the function as it is in code.Does not work:\[code\]$this -> DB = new PDO ("mysql:host={$hostname}; dbname={$dbname}", $username, $pw);\[/code\]works:\[code\]$this -> DB = new PDO ("mysql:host={$hostname};dbname={$dbname}", 'myname_user', 'password');\[/code\]I am hoping someone here can make me feel stupid... thanks in advance.-Davidthe error might help...\[quote\] Failed to get DB handle: SQLSTATE[28000] [1045] Access denied for user 'myname'@'localhost' (using password: NO)\[/quote\]
 
Back
Top