Re: MySQL query

From: Date: Wed, 28 Jan 2004 04:32:08 +0000
Subject: Re: MySQL query
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-176008@lists.php.net to get a copy of this message
On Wednesday 28 January 2004 12:05, Jason Giangrande wrote: > 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, Because mysql_query() returns FALSE only if there is an error in the query and something else otherwise. RTFM for details. > and anyone have any suggestions on > the easiest way to check to see if $link exists in the database before > updating it? "select website_link from link where website_link = '$link'" then use mysql_num_rows(). -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * ------------------------------------------ Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general ------------------------------------------ /* Everything you know is wrong! */

« previous php.general (#176008) next »