[newman] This don't work, "if" else if
| From: | Philip J. Newman | Date: | Thu, 21 Mar 2002 00:36:39 +0000 |
| Subject: | [newman] This don't work, "if" else if | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-89439@lists.php.net to get a copy of this message | ||
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);
}
?>
Philip J. Newman
PhilipNZ :: Design Solutions
http://www.philipnz.com/
info@philipnz.com
ICQ# 20482482
+64 25 6144012