Since I had no idea how to make a database I continued this way, and this is the result.
I called this function "onerror"
function ImgError(data) {
xmlhttp.open("POST","missing_image.php",false);
xmlhttp.send('src='+data.src);
data.src = "../../images/brokenlink.jpg";
}
created a missing_image.php with this the following code
<?php
$src = isset($_POST['src']) ? $_POST['src'] : NULL;
if( is_null($src) ) exit;
$file = file_get_contents('links.txt');
$pattern = '/<div[^>]+>\s<a[^>]+>\s<img src="'.preg_quote($src,'/').'"[^>]+>\s</a>\s</div>/';
if( preg_match($pattern,$file,$match) ) {
$newfile = str_replace($match[0],'',$file);
file_put_contents('links.txt',$newfile);
}
?>
Still not working.. Any idea?
(Thanks to Derokorian for the codes)