Connecting Tech Pros Worldwide Help | Site Map

T_ENCAPSED_AND_WHITESPACE error in fwrite() function.

Newbie
 
Join Date: Apr 2008
Posts: 23
#1: Jul 3 '08
Hi, I am trying to create a script that creates other php scripts but I am getting a problem, when I create the file and use fwrite() to write to it, it returns an error saying: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\wamp\www\setup2.php on line 32. Lines 28 - 62 of my script are:
Expand|Select|Wrap|Line Numbers
  1. touch("$folder_install/display_emails.php");
  2. if ($fp_display_emails=fopen("$folder_install/display_emails.php", "w")) {
  3.     fwrite($fp_display_emails,stripslashes("<?php
  4. session_start();
  5. if ($_SESSION[\'logged_in\'] != 1) {
  6.     header (\"Location: index.php\");
  7. }
  8. $conn=mysql_connect(\"".$mysql_server."\", \"".$mysql_username."\", \"".$mysql_password."\");
  9. mysql_select_db(\"".$mysql_database_name."\",$conn);
  10. $sql=\"SELECT * FROM list\";
  11. $result=mysql_query($sql,$conn);
  12. echo \"<table border=1 cellpadding=5>\";
  13. while ($newArray=mysql_fetch_array($result)) {
  14.     $id = $newArray[\'id\'];
  15.     $firstname = $newArray[\'firstname\'];
  16.     $email = $newArray[\'email\'];
  17.     echo \"
  18.             <tr>
  19.                 <td>
  20.                     <font face=\'arial\'>$id.</font>
  21.                 </td>
  22.                 <td>
  23.                     <font face=\'arial\'>\".ucfirst(strtolower($firstname)).\"</font>
  24.                 </td>
  25.                 <td>
  26.                     <font face=\'arial\'>\".strtolower($email).\"</font>
  27.                 </td>
  28.             </tr>
  29.         \";
  30. }
  31. echo \"</font></table>\";
  32. mysql_close($conn);
  33. ?>"));
  34. echo "The file display_emails.php was created!<br>";
  35. }
  36.  
Please help me, I am not even sure if you are allowed to create scripts inside scripts?

Line 32:
Expand|Select|Wrap|Line Numbers
  1. if ($_SESSION[\'logged_in\'] != 1) { 
(This is inside the fwrite() function)
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#2: Jul 3 '08

re: T_ENCAPSED_AND_WHITESPACE error in fwrite() function.


Why are you escaping the single quotes? There's no point.
Newbie
 
Join Date: Apr 2008
Posts: 23
#3: Jul 3 '08

re: T_ENCAPSED_AND_WHITESPACE error in fwrite() function.


don't worry, i have sorted this out now.
Reply