This is what i have:
define('DB_HOST', 'localhost');
define('DB_USER', 'someuser'); //or put you admin
define('DB_PASSWORD', 'somepassword');
define('DB_DATABASE', $databasename');
I want the $databasename thing to load some text from a textfile in the same directory Let's call it textfile.txt
How would i do this so it would work, tried several different things but it still doesn't work. I guess i'm missing some stuff.
Sounds a little dangerous, but I guess if your text file simply had a database name in it and nothing else:
$databasename = file_get_contents('textfile.txt');
would probably do it.
Originally posted by ShEx
Sounds a little dangerous, but I guess if your text file simply had a database name in it and nothing else:
$databasename = file_get_contents('textfile.txt');would probably do it.
That's what i tried first and it gives errors: T_CONSTANT_ENCAPSED_STRING That's what made me get stuck, don't understand it.
sounds like you have a stray
'
or
"
or
}
or something in your code.
define('DB_DATABASE', $databasename');
If you copied this directly from your code, that might be the culprit.
Originally posted by Tha.Riddla
sounds like you have a stray
'or"or}or something in your code.define('DB_DATABASE', $databasename');If you copied this directly from your code, that might be the culprit.
Yeah, the extra ' was too much but that didn't help much. I forgot that i was using includes and stuff so now i did:
$databasename = file_get_contents($_SERVER["DOCUMENT_ROOT"] . '/textfile.txt');
And now it works just fine, God i hate programming! 