Hi please could you advise.. I'm trying to prase a column in a table, to grep each field's contens, one contains a web page, and there are about 1000 pages in the column, thus they have to be one at a time so as not to over load the server /php .. the script below , gets an array of the table id's then using this array gets the total number of fields from the array. Thus geting the field to be grep'ed them grep'ing it then writing it back then moving on to the next field. this is the out put from the echo's with the full code below. Many Thanks in advance. <snip> SELECT idtemp FROM temp;0 query 2 SELECT file_content FROM temp WHERE idtemp = '1' Warning: mysql_real_escape_string() expects parameter 1 to be string, array given in /var/www/html/update_filecontent.php on line 36 query 3 UPDATE temp SET file_content = 'hello' WHERE idtemp = '1'; 1 Notice: Undefined offset: 1 in /var/www/html/update_filecontent.php on line 24 query 2 SELECT file_content FROM temp WHERE idtemp = '' Notice: Undefined offset: 1 in /var/www/html/update_filecontent.php on line 40 query 3 UPDATE temp SET file_content = 'hello' WHERE idtemp = ''; 2 Notice: Undefined offset: 2 in /var/www/html/update_filecontent.php on line 24 query 2 SELECT file_content FROM temp WHERE idtemp = '' Notice: Undefined offset: 2 in /var/www/html/update_filecontent.php on line 40 query 3 UPDATE temp SET file_content = 'hello' WHERE idtemp = ''; 3 </snip> <?php include './db_connection.inc'; // base line variables for testing $table = 'temp'; // the database name $column = 'file_content'; // the column within the the above table / $index = 'idtemp'; // the name of the id field within the above table $regy = '<\?php.*require.*header1.*\?>'; //regex used to carry out the replace $replace = ' '; // code to be inserted stepper($regy, $replace, $index, $table, $column); function stepper ($regy, $replace, $index, $table, $column ) { // used to parse $column... and carry out the updates $query = "SELECT ". $index ." FROM ".$table.";"; // get an array holding $index the column id. echo $query; $result = mysql_query($query) or die( mysql_error()); $i = 0; $index_Array = mysql_fetch_array($result); // push the 'id' array into an array varray variable While ($i < mysql_num_rows($result)) { // get number of rows, and assocated row id array echo $i."</br>"; $query2 = "SELECT ". $column ." FROM ". $table ." WHERE ".$index." = '". $index_Array[$i] ."'"; // query2 selects the field in the column containing the required strings //to be grep'ed and up dated echo "query 2 ".$query2 . "</br>"; //echo $query2."</br>"; //for testing $result2 = mysql_query($query2) or die( mysql_error()); $query_row = mysql_fetch_row($result2); $regex_input = $query_row; //echo $regex_input; //for testing $regex_ouput = preg_replace($regy, $replace, $regex_input); $sql_input = mysql_real_escape_string($regex_ouput); //echo $sql_input; //echo $regex_ouput; //for testing' $query3 = "UPDATE ".$table." SET " . $column . " = 'hello' WHERE ".$index." = '". $index_Array[$i]."';"; echo "query 3 " .$query3."</br>"; //$result3 = mysql_query($query3) or die( mysql_error()); $i++; } } mysql_close($link) ?> -- Gregory Machin greg@xxxxxxxxxxxxxx gregory.machin@xxxxxxxxx www.linuxpro.co.za Web Hosting Solutions Scalable Linux Solutions www.iberry.info (support and admin) www.goeducation (support and admin) +27 72 524 8096 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php