Simple Machines Community Forum

General Community => Scripting Help => Topic started by: Acf on September 29, 2003, 12:02:48 PM

Title: What am i doing wrong?
Post by: Acf on September 29, 2003, 12:02:48 PM
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
Title: Re:What am i doing wrong?
Post by: Spaceman-Spiff on September 29, 2003, 02:11:54 PM
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 "
Title: Re:What am i doing wrong?
Post by: Acf on September 29, 2003, 03:16:33 PM
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";
  }
?>
Title: Re:What am i doing wrong?
Post by: [Unknown] on September 29, 2003, 03:30:37 PM
For $user =, etc. you need to escape the $ since you are using double quotes.

-[Unknown]
Title: Re:What am i doing wrong?
Post by: Acf on September 29, 2003, 03:55:29 PM
Thanx  Spaceman-Spiff and  [Unknown] ,  it works like a dream!  :)  :)  :)