I'm reading in to a variable $section1 an entire php file that creates a mysql table. I can output the variable in a new file just fine (figured out what all had to be escaped in the original file).
My problem is, I want to replace the table name in the original file with a new table name before I output it to the new file. But the str_replace has no effect. Neither does an ereg_replace. Is there something in the content of the file that is foiling the replace? Here is what I have right now. It produces the same file content as is read in. <?php $search = "item"; $replace = "poem"; mkdir($replace, 0777); $section1 = file_get_contents("table_create.php"); str_replace($search, $replace, $section1); chdir($replace); $table_create = fopen($replace."_table_create.php","w+"); fwrite($table_create,$section1); ?> The file I'm reading in is as follows: <?php session_start(); ?> <?php $title = "$PHP_SELF"; ?> <?php include ("../resources/header.php"); ?> <?php include("../resources/db_connect.php"); ?> <? // build the query $sql = "CREATE TABLE item ( i_item_id int primary key not null default '0' auto_increment, i_client varchar(30), i_project varchar(30), i_category varchar(30), i_phase varchar(30), i_type varchar(30), i_priority decimal(8,2), i_author varchar(30), i_created date, i_owner varchar(30), i_due date, i_status varchar(30), i_title varchar(50), i_file varchar(50), i_url varchar(100), i_detail mediumtext, FULLTEXT (i_title,i_url,i_file,i_detail) )"; // execute the query $result = mysql_query($sql,$connection) or die(mysql_error()); if ($result) { $msg = "<p>The table has been created.</p>"; } else { $msg = "<p>echo mysql_error()</p>"; } // reveal what happened echo "$msg"; ?> <?php include("../resources/footer.php"); ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php