Re: MySQL query

From: Date: Thu, 29 Jan 2004 04:14:25 +0000
Subject: Re: MySQL query
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-176007@lists.php.net to get a copy of this message
Jason Giangrande wrote:
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?
There's nothing technically wrong with the query, it simply doesn't match a link so nothing is updated. That doesn't mean the query fails. Anyhow, use mysql_affected_rows() to see if any rows were affected by your query. If it's zero, then the link probably doesn't exist. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com

« previous php.general (#176007) next »