So I've been working on this little script but I am trying to accomplish something that seems to not be working. I have done this in one of my scripts some time ago but for some reason I can not get it to work now. I have created a php file named config.php and what I would like to do is enter a value into some variables in that file such ad dbhost and dbuser and dbpass using a basic form with basic text fields. Sample Config Layout. <? $dbhost = 'Value to go here!'; $dbuser = 'Value to go here!'; $dbpass = 'Value to go here!'; $dbuser = 'Value to go here!'; ?> PHP: I have just tried to accomplish this using fwrite but since its been so long since I've done this I cant get it rite. I know there are many of you that do this on a daily basis so a little help would be greatly appreciated. Cheers!
Something on the lines of... $file = 'config.php'; $fh = fopen($file, 'w') or die('can't open config.php file chomd to 0777.'); $filedata = " <? /$var1 = 'Something'; /$var2 = 'Something2 etc...'; ?> "; fwrite($fh, $filedata); fclose($fh); PHP:
Yea, I created it so far so that it creates the config file and sets the permissions to 777 and then it writes to it.
You see, I even copied your code word for word and I receive the same result. <? / = '1'; / = '1'; ?> PHP: Is what shows up in the config file lol
What about chaging: $filedata = " <? /$var1 = 'Something'; /$var2 = 'Something2 etc...'; ?> "; PHP: to $filedata = ' <? $var1 = "something"; $var2 = "Something2 etc..."; ?> '; PHP: And if that does not work, why not use defines instead of variables, personal preference :-P
Nope I get the same effect, for some reason any code that I have tried to get this to work does not insert anything that looks like a variable unless it has a value. I remember there was some way to do this but I cant remember. hmmmmmm