inserting IP ADD into Mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
sakaveli
Forum Commoner
Posts: 60
Joined: Tue Apr 06, 2004 9:42 am

inserting IP ADD into Mysql

Post by sakaveli »

hi ppl,

im trying to log IP addresses soon as sum1 logs onto my site, and store them into a DB, but im not sure what the query would look like?

i think that $_SERVER["REMOTE_ADDR"] holds the ip add, is that right? what would the insert statement look like for this?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

to simple add an ip to the database it would look something like

Code: Select all

$sql = "INS-ERT INTO `ips` SET `ip` = '".$_SERVER['REMOTE_ADDR']."'";


notice that INS-ERT should be INSERT, some problems with the server wont allow me to type it properly
User avatar
cto1mac
Forum Commoner
Posts: 54
Joined: Tue Jan 27, 2004 6:11 am
Location: Virginia Beach, VA

Post by cto1mac »

I tried to post that reply like 6 times, but, it kept erroring out. Is the insert the problem?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

cto1mac wrote:I tried to post that reply like 6 times, but, it kept erroring out. Is the insert the problem?
I tried finding the thread, but feyd narrowed the problem down to a few words that arn't being accepted.

edit: i found it

viewtopic.php?t=27017
Post Reply