I have the following query. UPDATE link SET hits = hits+1 WHERE website_link = '$link'
$link is the website link that was clicked on.
The query works fine. The problem is if $link is a website that does
not exist in the database mysql_query(); still returns true even though
nothing was updated. Why is this, and anyone have any suggestions on
the easiest way to check to see if $link exists in the database before
updating it?
Here's the code. db_error() is a function that calls mysql_error() and a
few other things.
$link = $_GET['link'];
$query = "UPDATE link SET hits = hits+1 WHERE website_link = '$link'";
$result = @ mysql_query($query, $connection) or db_error();
var_dump($result); // True even if $link does not exist in database.
header("Location: $link");
die();
** db_error() function **
function db_error() { // Dies with fatal error
global $db_name;
if (mysql_error()) {
die("Error " . mysql_errno() . ": " . mysql_error());
} else {
die("Could not connect to database, $db_name");
}
}
--
Jason Giangrande <[EMAIL PROTECTED]>
signature.asc
Description: This is a digitally signed message part

