T_ENCAPSED_AND_WHITESPACE error in fwrite() function.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • miraan
    New Member
    • Apr 2008
    • 24

    T_ENCAPSED_AND_WHITESPACE error in fwrite() function.

    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\set up2.php on line 32. Lines 28 - 62 of my script are:
    Code:
    touch("$folder_install/display_emails.php");
    if ($fp_display_emails=fopen("$folder_install/display_emails.php", "w")) {
    	fwrite($fp_display_emails,stripslashes("<?php
    session_start();
    if ($_SESSION[\'logged_in\'] != 1) {
    	header (\"Location: index.php\");
    }
    $conn=mysql_connect(\"".$mysql_server."\", \"".$mysql_username."\", \"".$mysql_password."\");
    mysql_select_db(\"".$mysql_database_name."\",$conn);
    $sql=\"SELECT * FROM list\";
    $result=mysql_query($sql,$conn);
    echo \"<table border=1 cellpadding=5>\";
    while ($newArray=mysql_fetch_array($result)) {
    	$id = $newArray[\'id\'];
    	$firstname = $newArray[\'firstname\'];
    	$email = $newArray[\'email\'];
    	echo \"
    			<tr>
    				<td>
    					<font face=\'arial\'>$id.</font>
    				</td>
    				<td>
    					<font face=\'arial\'>\".ucfirst(strtolower($firstname)).\"</font>
    				</td>
    				<td>
    					<font face=\'arial\'>\".strtolower($email).\"</font>
    				</td>
    			</tr>
    		\";
    }
    echo \"</font></table>\";
    mysql_close($conn);
    ?>"));
    echo "The file display_emails.php was created!<br>";
    }
    Please help me, I am not even sure if you are allowed to create scripts inside scripts?

    Line 32:
    Code:
    if ($_SESSION[\'logged_in\'] != 1) {
    (This is inside the fwrite() function)
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Why are you escaping the single quotes? There's no point.

    Comment

    • miraan
      New Member
      • Apr 2008
      • 24

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

      Comment

      Working...