News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

What am i doing wrong?

Started by Acf, September 29, 2003, 12:02:48 PM

Previous topic - Next topic

Acf

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
Sigh...

Spaceman-Spiff

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 "

Acf

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";
  }
?>
Sigh...

[Unknown]

For $user =, etc. you need to escape the $ since you are using double quotes.

-[Unknown]

Acf

Thanx Spaceman-Spiff and  [Unknown] ,  it works like a dream!  :)  :)  :)
Sigh...

Advertisement: