Advertisement:

Author Topic: What am i doing wrong?  (Read 5197 times)

Offline Acf

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,967
  • Gender: Male
  • 101101010112
What am i doing wrong?
« 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).

Code: [Select]
<?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.

Code: [Select]
<?php
$user 
="username";
$wachtwoord ="Password";
$database ="databasename"
$server ="localhost";
?>

 

*acf
Sigh...

Offline Spaceman-Spiff

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 1,524
  • Gender: Male
Re:What am i doing wrong?
« Reply #1 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 "

Offline Acf

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,967
  • Gender: Male
  • 101101010112
Re:What am i doing wrong?
« Reply #2 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";
  }
?>
Sigh...

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re:What am i doing wrong?
« Reply #3 on: September 29, 2003, 03:30:37 PM »
For $user =, etc. you need to escape the $ since you are using double quotes.

-[Unknown]

Offline Acf

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,967
  • Gender: Male
  • 101101010112
Re:What am i doing wrong?
« Reply #4 on: September 29, 2003, 03:55:29 PM »
Thanx Spaceman-Spiff and  [Unknown] ,  it works like a dream!  :)  :)  :)
Sigh...