Jax2 Posted March 16, 2010 Share Posted March 16, 2010 Hello guys, got a question that will hopefully be simple for someone to answer .... I have a file named db.php that looks like this: <?php $db_host=""; $db_username=""; $db_dbname=""; $db_password=""; $db_prefix=""; ?> Now, what I am trying to do is to create an installation script for something I am working on. The very first part allows the user to configure their database (MySQL) ... (Yes, I am off to a shaky start already ) I have the variables stored in $_POST and they all display fine, but I am not sure how to write to the file. I've read the manual on fopen, and I'm rather lost. I just want to have it add the variables where they go, so it looks more like this when it's done: $db_host="localhost"; $db_username="MyName"; $db_dbname="DataBaseName"; $db_password="DBPassword"; $db_prefix="PF_"; Could anyone help me out here and perhaps point me to a good tutorial or something of that nature? Thank you! Link to comment https://forums.phpfreaks.com/topic/195402-overwriting-variables-in-a-file-with-php/ Share on other sites More sharing options...
Rustywolf Posted March 16, 2010 Share Posted March 16, 2010 use fopen, fread and fwrite to get values and str_replace $variable="" with $variable="$value" Link to comment https://forums.phpfreaks.com/topic/195402-overwriting-variables-in-a-file-with-php/#findComment-1026824 Share on other sites More sharing options...
plznty Posted March 16, 2010 Share Posted March 16, 2010 I recommend directing the data to a page to check if the sql can be connected to through the input connection details, then to post the data yet again to a filewrite system if it works. Link to comment https://forums.phpfreaks.com/topic/195402-overwriting-variables-in-a-file-with-php/#findComment-1026868 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.