[PHP] Trying to put ips into database

2002-02-08 Thread Leif K-Brooks

I'm trying:
$query = mysql_query(select COUNT(*) as rowexists from ips where ip =
'$REMOTE_ADDR');
$result = mysql_fetch_array($query);
if($result['rowexists'] == false){
mysql_query(INSERT INTO `ips` (`ip`) VALUES ('$REMOTE_ADDR'));
}


But it keeps putting the ip into tthe array, even if it's already there, and
it only gets the first section of the ip!  What am I doing wrong? 



Re: [PHP] Trying to put ips into database

2002-02-08 Thread Dennis Moore

Not sure what your exact problem is but I did notice you had back ticks(`)
in your insert statement.  You should be using (').   You may need a where
clause in your insrt statement unless you want to populate all rows.  Just a
couple of thoughts.

/dkm


- Original Message -
From: Leif K-Brooks [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, February 08, 2002 11:18 AM
Subject: [PHP] Trying to put ips into database


 I'm trying:
 $query = mysql_query(select COUNT(*) as rowexists from ips where ip =
 '$REMOTE_ADDR');
 $result = mysql_fetch_array($query);
 if($result['rowexists'] == false){
 mysql_query(INSERT INTO `ips` (`ip`) VALUES ('$REMOTE_ADDR'));
 }


 But it keeps putting the ip into tthe array, even if it's already there,
and
 it only gets the first section of the ip!  What am I doing wrong?



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




Re: [PHP] Trying to put ips into database

2002-02-08 Thread Matt Drake

On Fri, 8 Feb 2002, Dennis Moore wrote:

 Not sure what your exact problem is but I did notice you had back ticks(`)
 in your insert statement.  You should be using (').   You may need a where
 clause in your insrt statement unless you want to populate all rows.  Just a
 couple of thoughts.

Actually, you don't need quotes around the col. names at all...

mysql_query(INSERT INTO ips (ip) VALUES ('$REMOTE_ADDR'));

As for only getting the first part, are you sure the ip field is big enough?
Try explain ips from a mysql client...it should be at least 15 chars.

Matt


 /dkm


 - Original Message -
 From: Leif K-Brooks [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Friday, February 08, 2002 11:18 AM
 Subject: [PHP] Trying to put ips into database


  I'm trying:
  $query = mysql_query(select COUNT(*) as rowexists from ips where ip =
  '$REMOTE_ADDR');
  $result = mysql_fetch_array($query);
  if($result['rowexists'] == false){
  mysql_query(INSERT INTO `ips` (`ip`) VALUES ('$REMOTE_ADDR'));
  }
 
 
  But it keeps putting the ip into tthe array, even if it's already there,
 and
  it only gets the first section of the ip!  What am I doing wrong?
 


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




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




Re: [PHP] Trying to put ips into database

2002-02-08 Thread Daniel C. BAUFAY

And for efficiency you could convert and store IP addresses in numeric 
format.
See INET_NTOA and INET_ATON.





Subject:

Re: [PHP] Trying to put ips into database
From:

Matt Drake [EMAIL PROTECTED]
Date:

Fri, 8 Feb 2002 11:52:26 -0600 (CST)

To:

[EMAIL PROTECTED]


On Fri, 8 Feb 2002, Dennis Moore wrote:


 Not sure what your exact problem is but I did notice you had back ticks(`)
 in your insert statement.  You should be using (').   You may need a where
 clause in your insrt statement unless you want to populate all rows.  Just a
 couple of thoughts.

 




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




RE: [PHP] Trying to put ips into database

2002-02-08 Thread Matthew Walker

What type of field is 'ip'?

Matthew Walker
Ecommerce Project Manager
Mountain Top Herbs


-Original Message-
From: Leif K-Brooks [mailto:[EMAIL PROTECTED]] 
Sent: Friday, February 08, 2002 9:18 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Trying to put ips into database

I'm trying:
$query = mysql_query(select COUNT(*) as rowexists from ips where ip =
'$REMOTE_ADDR');
$result = mysql_fetch_array($query);
if($result['rowexists'] == false){
mysql_query(INSERT INTO `ips` (`ip`) VALUES ('$REMOTE_ADDR'));
}


But it keeps putting the ip into tthe array, even if it's already there,
and
it only gets the first section of the ip!  What am I doing wrong? 

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.323 / Virus Database: 180 - Release Date: 2/8/2002
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.323 / Virus Database: 180 - Release Date: 2/8/2002
 

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