I believe it already does this, which is the confusing part. It's a really big code, but here's a representative snippet:
Code:
$query = "SELECT aff, url, des, thumb FROM $table WHERE id = '$key'";
$result = mysql_query($query);
$exists = mysql_num_rows($result);
$dbrow = mysql_fetch_row($result);
mysql_free_result($result);
if ($exists) {
$dbrow = implode("|", $dbrow);
$postrow = "$aff|$url|$des|$thumb";
if ($dbrow == $postrow) {
$message[] = "";
} else if (trim($postrow, "|") == "") {
$query_2 = "DELETE FROM $table WHERE $table.id = $key LIMIT 1";
} else {
$url_id = array_search($url, $url_set);
if (($url_id == $key) || ($url_id === false)) {
$query_2 = "UPDATE $table SET url = '$url', des = '$des', thumb = '$thumb', aff='$aff' WHERE id = '$key'";
} else {
$message[] = " <small>Error: duplicate url -- $url </small><br/>\n";
}
}
} else if (!$exists) {
if (trim($value, "|") != "") {
if (in_array($url, $url_set)) {
$message[] = " <small>Error: duplicate url -- $url </small><br/>\n";
} else {
$query_2 = "INSERT INTO $table (id, star, aff, url, base_url, des, thumb) VALUES ('$key', '$passthru', '$aff', '$url', '$base_url', '$des', '$thumb')";
}
}
}
$result_2 = mysql_query($query_2);
if ($result_2) {
$message[] = "Successfully updated the database<br/>\n";
mysql_free_result($result_2);
} else {
$message[] = "Error updating $table: " . mysql_error() . "<br/>\n";
}
unset($aff); unset($url); unset($des); unset($thumb);
this is, as you can imagine, part of a foreach which loops about a hundred times.
I had connected to mysql by way of mysql_pconnect() until about four or five hours ago when i changed it to mysql_connect(), thinking that this would free up some memory. Should i change it back?
Bookmarks