Jump to content

[SOLVED] Writing to a File


monkeypaw201

Recommended Posts

i am trying to write to a file... BUT im trying to write PHP code to a file and it doesnt work...

 

<?php
$ourFileName = "data.php";
$ourFileHandle = fopen($ourFileName, 'w') or die("<font color='red'>Error creating file</font>");
fclose($ourFileHandle);

$myFile = "data.php";
$fh = fopen($myFile, 'w') or die("<font color='red'>Error Writing to file</font>");
$stringData = "<?php \n\n$SETTINGS = Array (\n\n";
fwrite($fh, $stringData);
$stringData = "$hostname_conn_abrv";
fwrite($fh, $stringData);
$stringData = " = " . $_POST['server'] . ";   //database hostname, usually always localhost\n";
fwrite($fh, $stringData);
$stringData = "$database_conn_abrv";
fwrite($fh, $stringData);
$stringData = " = " . $_POST['database'] . "; //database name\n";
fwrite($fh, $stringData);
$stringData = "$username_conn_abrv";
fwrite($fh, $stringData);
$stringData = " = " . $_POST['user'] . "; // database username\n";
fwrite($fh, $stringData);
$stringData = "$password_conn_abrv";
fwrite($fh, $stringData);
$stringData = " = " . $_POST['pass'] . "; // database \n";
fwrite($fh, $stringData);
$stringData = "\n$conn_abrv = mysql_pconnect($hostname_conn_abrv, $username_conn_abrv, $password_conn_abrv) or trigger_error(mysql_error(),E_USER_ERROR); 

\n\n

); \n?>";
fwrite($fh, $stringData);
fclose($fh);
?>

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/115478-solved-writing-to-a-file/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.