I store all of my login information for databases in files outside of the public tree in variables such as
$hostname = '172.0.0.0';
$dbname = 'myname_mydbname';
$username = 'myname_user';
$pw = 'password';
That's pretty standard.
The problem is that this particular hosting I am working with requires the myname_
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:
$this -> DB = new PDO ("mysql:host={$hostname}; dbname={$dbname}", $username, $pw);
works:
$this -> DB = new PDO ("mysql:host={$hostname};dbname={$dbname}", 'myname_user', 'password');
I am hoping someone here can make me feel stupid... thanks in advance. -David
the error might help...
Failed to get DB handle: SQLSTATE[28000] [1045] Access denied for user 'myname'@'localhost' (using password: NO)