#!/web/cgi-bin/php5 0) { echo "found href\n"; continue; } $offset = 0; $stpos = strpos ($txt, " www.", $offset); $endpos = strpos ($txt, ".com", $stpos); $site = substr ($txt, $stpos + 1, $endpos + 4 - $stpos - 1); //echo $stpos . " " . $endpos . "\n"; echo $site . "\n"; $tofind = "/" . $site . "/"; $toreplace = ''.$site.''; echo $toreplace; $updatedTxt = preg_replace ($tofind, $toreplace, $txt); $sql = "UPDATE articles set body=\"".mysql_real_escape_string($updatedTxt)."\" where aid='" . $row["aid"] . "'"; //echo $sql . "\n"; //echo $updatedTxt . "\n"; mysql_query ($sql); echo mysql_error(); } mysql_close ($connection); } catch (Exception $e) { // catch the exception and display the error message echo "

The following error has occurred: " . $e->getMessage() . "
"; } ?>