Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1669 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

Storing an IP in a Database

Thread title: Storing an IP in a Database
Closed Thread    
    Thread tools Search this thread Display Modes  
07-28-2006, 08:47 PM
#1
Jako is offline Jako
Jako's Avatar
Status: Jakowenko.com
Join date: Jun 2005
Location: Michigan
Expertise:
Software:
 
Posts: 2,199
iTrader: 3 / 100%
 

Jako is on a distinguished road

  Old  Storing an IP in a Database

I have this much,
PHP Code:
$ip $_SERVER['REMOTE_ADDR']; 
But how do I store the IP of someone who submits a form and keep it in the database?

07-28-2006, 11:26 PM
#2
Barbaro is offline Barbaro
Barbaro's Avatar
Status: Member
Join date: Feb 2006
Location: Omaha, NE
Expertise:
Software:
 
Posts: 452
iTrader: 1 / 100%
 

Barbaro is on a distinguished road

  Old

mysql_query("INSERT INTO ip VALUES ($ip)");

07-28-2006, 11:43 PM
#3
Jeff Andersen is offline Jeff Andersen
Status: Superstar
Join date: Apr 2005
Location:
Expertise:
Software:
 
Posts: 4,449
iTrader: 10 / 100%
 

Jeff Andersen is on a distinguished road

  Old

Yep, anything like:
Code:
<?
$ip = $_SERVER['REMOTE_ADDR'];   
MYSQL_QUERY("INSERT INTO internetprotocols VALUES ($ip)");
?>
Will work.

07-29-2006, 02:59 AM
#4
dre is offline dre
Status: Junior Member
Join date: Jul 2006
Location:
Expertise:
Software:
 
Posts: 42
iTrader: 0 / 0%
 

dre is on a distinguished road

  Old

PHP Code:
<?
//db connection or config file
$ip $_SERVER['REMOTE_ADDR'];   
MYSQL_QUERY("INSERT INTO ip VALUES ($ip)");
?>
You will also need to set up a table called "ip"

07-29-2006, 03:12 AM
#5
Andrew R is offline Andrew R
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
 
Posts: 5,200
iTrader: 17 / 95%
 

Andrew R is on a distinguished road

  Old

May I point out that all your codes are exactly the same except for the name of the table? What is the point in posting the same thing twice..

07-29-2006, 08:24 AM
#6
dre is offline dre
Status: Junior Member
Join date: Jul 2006
Location:
Expertise:
Software:
 
Posts: 42
iTrader: 0 / 0%
 

dre is on a distinguished road

  Old

Well, the guy obv. doesnt know php that well. Fair enough he's trying to learn...we were pointing him in the right direction. Everyone has a different coding style...

07-29-2006, 03:26 PM
#7
Village Genius is offline Village Genius
Village Genius's Avatar
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
 
Posts: 6,894
iTrader: 18 / 100%
 

Village Genius will become famous soon enough

  Old

it should be a varchar 15

07-30-2006, 08:22 PM
#8
localhost is offline localhost
localhost's Avatar
Status: Dediport Hosting
Join date: Jul 2006
Location: Berkshire
Expertise: programming, business
Software: Dreamweaver
 
Posts: 1,316
iTrader: 17 / 100%
 

localhost is on a distinguished road

  Old

Also, they given you this code but are you storing just everyones ip or other information with it, if your just storing the ip is assume you are trying to count how many unique users onto your site but to stop it storing the same twice i think you should have a field called count.

07-30-2006, 08:32 PM
#9
Jako is offline Jako
Jako's Avatar
Status: Jakowenko.com
Join date: Jun 2005
Location: Michigan
Expertise:
Software:
 
Posts: 2,199
iTrader: 3 / 100%
 

Jako is on a distinguished road

  Old

I got it working, it was already for an exisiting site that is with other info. Thanks for the help you guys.

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed