I am making a installer and i would like to put the db, user and pw in a file with a form.
This is what i made so far (it does display some parse errors).
<?php
$file = fopen ("Dbconfig.php","a" );
if(!$file)
{
echo "Failed to open Dbconfig.php\n";
} else {
fputs($file, "<");
fputs($file, "?php \n");
fputs($file, "$user ="$t1"; \n");
fputs($file, "$wachtwoord ="$t2"; \n");
fputs($file, "$database ="$t3"; \n");
fputs($file, "$server ="$t4"; \n");
fputs($file, "?");
fputs($file, "> \n");
fclose($file);
echo "Dbconfig.php written correctly\n";
}
?>
This what the file should look like after the form is used.
<?php
$user ="username";
$wachtwoord ="Password";
$database ="databasename";
$server ="localhost";
?>
*acf
using the highlighter u can find the mistake easier:
<?php
fputs($file, "$user ="$t1"; \n");
fputs($file, "$wachtwoord ="$t2"; \n");
fputs($file, "$database ="$t3"; \n");
fputs($file, "$server ="$t4"; \n");
?>
you didn't escape the " inside "
Parse error: parse error in /home/thecrew/public_html/aliencowfarm/test/Install.php on line 5
thanx if don so but now i get the error above.
<?php
$file = fopen ("Dbconfig.php","a" );
if(!$file)
{
echo "Failed to open Dbconfig.php\n";
} else {
fputs($file, "<");
fputs($file, "?php \n");
fputs($file, "$user =\"$t1\"; \n");
fputs($file, "$wachtwoord =\"$t2\"; \n");
fputs($file, "$database =\"$t3\"; \n");
fputs($file, "$server =\"$t4\"; \n");
fputs($file, "?");
fputs($file, "> \n");
fclose($file);
echo "Dbconfig.php written correctly\n";
}
?>
For $user =, etc. you need to escape the $ since you are using double quotes.
-[Unknown]
Thanx Spaceman-Spiff and [Unknown] , it works like a dream! :) :) :)