TwelvestoneBack End

MySQL database problem


Sign in

  • Waiting for Godot ( 730 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 5.1 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.9 k posts )
    general front end design an...
  • Back End ( 9.7 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
The General
 
2012-01-19

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.

ShEx
 
2012-01-19

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.

The General
 
2012-01-19

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.

Tha.Riddla
 
2012-01-19

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.

The General
 
2012-01-19

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! k

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneBack End

MySQL database problem