ballhogjoni Posted August 21, 2008 Share Posted August 21, 2008 I want to write this code to a php file but when it does it excludes the variables string written to the x.php file: $stringData = "<?php"; $stringData .= " include('../config.php');"; $stringData .= "$oDB = new FACSDatabase();"; $stringData .= "$rResult = $oDB->Select('".$aUploadImageInfo['db_table']."','".$aUploadImageInfo['db_data']."','".$aUploadImageInfo['db_where']."');"; $stringData .= "while( $row = mysql_fetch_array( $rResult ) ){"; $stringData .= "$article = '<div class=\'style15\'>'"; $stringData .= ".$row[title].'</div><font size=\'2\' color=\'#999999\'>"; $stringData .= "By '.$row[author].'</font><hr />'.$row[tinymcedata];"; $stringData .= "}include('".$aUploadImageInfo['mainFile']."');"; $stringData .= "?>"; code in the x.php file: <?php include('../config.php'); = new FACSDatabase(); = ('Articles as a,Authors as au','a.*,au.*','WHERE a.article_id = '' AND a.author_id = au.author_id');while( = mysql_fetch_array( ) ){ = '<div class=\'style15\'>'..'</div><font size=\'2\' color=\'#999999\'>By '..'</font><hr />'.;}include('');?> My question is how to I write this code to make php write all the variables and not replace them as nothing? Basically it looks like php is erasing my variables. Here's the entire function: function CreateUploadDirectoriesImages($aUploadImageInfo,$Files){ $result = ''; $filepath = '/home/xxx/www/xxx/'.$aUploadImageInfo['secondary_folder']."/".$aUploadImageInfo['article_folder_name']; if(!is_dir($filepath)) { mkdir($filepath,0777); } if(!is_dir($filepath . 'images/')) { mkdir($filepath . '/images/',0777); } if( !file_exists($filepath.'/index.php') ){ $newFile = $filepath."/index.php"; $fh = fopen($newFile, 'w') or die("can't create file"); $stringData = "<?php"; $stringData .= " include('../config.php');"; $stringData .= "$oDB = new FACSDatabase();"; $stringData .= "$rResult = $oDB->Select('".$aUploadImageInfo['db_table']."','".$aUploadImageInfo['db_data']."','".$aUploadImageInfo['db_where']."');"; $stringData .= "while( $row = mysql_fetch_array( $rResult ) ){"; $stringData .= "$article = '<div class=\'style15\'>'"; $stringData .= ".$row[title].'</div><font size=\'2\' color=\'#999999\'>"; $stringData .= "By '.$row[author].'</font><hr />'.$row[tinymcedata];"; $stringData .= "}include('".$aUploadImageInfo['mainFile']."');"; $stringData .= "?>"; fwrite($fh, $stringData); fclose($fh); } $filepath = $filepath.'/images/'.basename( $Files['name']); if(move_uploaded_file($Files['tmp_name'], $filepath)) { $result = "The file ".basename( $Files['name'])." has been uploaded"; }else{ $result = "There was an error uploading the file, please try again!"; } return $result; } Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 21, 2008 Share Posted August 21, 2008 Use single quotes to get the literal variable name: $variable = 1; echo '$variable = 1'; That would output "$variable = 1" If it were double quotes it would be "1 = 1" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.