This code won't execute the script if there is an error with the SQL Query:
PHP Code:
<?
if ( mysql_pconnect("mysql.4ph.com","jonhill","changeme") === FALSE)
echo "ERROR: Could Not Successfully Connect to DB Server<br>\nSQL ERROR:".mysql_error()."<br>\n";
if ( mysql_select_db("counter") === FALSE)
echo "ERROR: Could Not Select Database<br>\nSQL ERROR:".mysql_error()."<br>\n";
if ( ($result = mysql_query("select * from counter WHERE url='$url'")) === FALSE)
echo "ERROR: Error executing query:<br>\nSQL ERROR:".mysql_error()."<br>\n";
else {
while($r=mysql_fetch_array($result)) {
$id=$r["id"];
$count=$r["count"];
$url=$r["url"];
$count++;
$update = "UPDATE counter SET count='$count' WHERE id=$id";
$updatesql = mysql_query($update);
?>
<script language="JavaScript">
document.location.href="<?php echo $url;?>"
</script>
<?
}
}
?>