RE: [PHP] [newman] This don't work, if else if

2002-03-21 Thread Rick Emery

if (mysql_num_rows($sql_result)  0) {

FYI:  thank you for providing full code and what the algorithm is supposed
to accomplish.  Most posters do not.

-Original Message-
From: Philip J. Newman [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 20, 2002 6:37 PM
To: [EMAIL PROTECTED]
Subject: [PHP] [newman] This don't work, if else if


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/
[EMAIL PROTECTED]
ICQ# 20482482
+64 25 6144012

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] [newman] This don't work, if else if

2002-03-20 Thread Philip J. Newman

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/
[EMAIL PROTECTED]
ICQ# 20482482
+64 25 6144012