Re: [newman] This don't work, "if" else if

From: Date: Thu, 21 Mar 2002 04:47:22 +0000
Subject: Re: [newman] This don't work, "if" else if
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-89457@lists.php.net to get a copy of this message
In article <001001c1d070$76ef8dd0$0401a8c0@philip>, newmanpj@philipsdomain.com says... > Can anyone tell me why this isn't working? What its ment to do is add an IP number to the > database. if the IP is all ready in the database then it would update a counter. > > > <?php > > $proxy_ip=getenv('REMOTE_ADDR'); > $proxy_dns=gethostbyaddr($proxy_ip); > $add_date=date ("d/F/Y @ h:i:s A"); > > $sql = "SELECT accessIP FROM access ORDER BY > accessID DESC"; > $sql_result = mysql_query($sql, $connection) or die ("Could not get Query"); > > $row = mysql_fetch_array($sql_result); > $accessIP = $row["accessIP"]; > > if (mysql_num_rows($sql_result) < 0) { > > // Update view where ip = visitor_ip > mysql_query("UPDATE access SET accessVIEW = accessVIEW+1 WHERE accessIP = > $accessIP"); > > } else { > > // Normal insert > $sql = "INSERT INTO access > (accessID, accessIP, > accessDNS, accessTIME, > accessUPDATE, accessVIEW) VALUES > ('', '$proxy_ip', '$proxy_dns', '$add_date', NOW(NULL), > '0')"; > $result = mysql_query($sql); > } > > ?> Seems to me that you are treating accessIP as a string in one and an integer in the other query. -- David Robley Temporary Kiwi! Quod subigo farinam

« previous php.general (#89457) next »