fergald Posted December 12, 2007 Share Posted December 12, 2007 Hi, please forgive me if this is a stupid question or in the wrong area. I have a piece of code wrote in a php page similar to this $filename=$_SERVER["DOCUMENT_ROOT"]."/Training/fred.php"; $fh = fopen($filename, 'w') or die("can't open file"); $theData="<? unset($_SESSION\['page']); $user = $color; //echo \"fergal user is $color\"; if($user==\"\"){ $receivedfoldername=$_REQUEST\[\"user\"]; if ($receivedfoldername == \"\"){ }else{ $color=$receivedfoldername; } } "; fwrite($fh, $theData); fclose($fh); now when i execute this its fine, then i go to my fred.php which is create with theData and if fails i think the problem is here unset($_SESSION\['page']); it does not like strings containing [] - is their a way to avoid this or am i doing this totally wrong. Any help would be much appreciated. Kind Regards Fergal. Link to comment https://forums.phpfreaks.com/topic/81347-question-about-fwrite-and-square-bracket-beginner-user/ Share on other sites More sharing options...
trq Posted December 12, 2007 Share Posted December 12, 2007 You'll want to use single quotes around the data. <?php $theData = '<? unset($_SESSION["page"]); $user = $color; //echo "fergal user is $color"; if($user==""){ $receivedfoldername=$_REQUEST["user"]; if ($receivedfoldername == ""){ }else{ $color=$receivedfoldername; } } ?>'; I'm really not sure why you would be wanting to dynamically generate php though. Link to comment https://forums.phpfreaks.com/topic/81347-question-about-fwrite-and-square-bracket-beginner-user/#findComment-412851 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.