I wrote the following script to take the word 'the' out of my titles as it is now in its own column. It worked with 'A' and then 'An', but when I changed to 'The', the query looped twice then died. I thought maybe it was just the server was down but after trying later it still just dies. Any theories?
Dave
/ test Title string to see if it begins with the. /
include ("../functions.inc");
db_connect();
$query = "SELECT Title FROM my_table WHERE Title REGEXP '^The '";
$result = mysql_db_query ("my_db", $query)
or die ("Cannot EXECUTE query");
$num_results = mysql_num_rows($result);
for ($i=0; $i < $num_results; $i++)
{
$row = mysql_fetch_array($result);
$old_title = $row["Title"];
$length = strlen($row["Title"]);
$length = $length-1;
$new_title = substr($row["Title"], 4, $length);
$query_a = "UPDATE my_table SET Title='$new_title' WHERE Title='$old_title'";
$result_a = mysql_db_query ("my_db", $query_a)
or die ("Cannot execute update query");
echo "$new_title was updated";
}