PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old June 27th, 2002, 11:18 AM
D1NGO D1NGO is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Perth, Australia
Posts: 221 D1NGO User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Adding an IP

Heya, i'm trying to add IP's into a DB, although, it only ever adds the first set of number before the first decimal.. (ie. if IP is 202.45.75.312, it will only add 202)
any ideas on why this happens? i'm guessing the solution will have something to do with escaping the decimals, but i'm not sure

Reply With Quote
  #2  
Old June 27th, 2002, 12:52 PM
CmdrDats CmdrDats is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: <br><img src='http://www.dats.co.za/icon.gif'>
Posts: 269 CmdrDats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to CmdrDats Send a message via AIM to CmdrDats Send a message via Yahoo to CmdrDats
RE: Adding an IP

What type of field are you using? If ur using integer, it will obviously not include the entire thing.. Use varchar or tinytext (i'd use tinytext.. just matter of preference somehow)

The other option is to simply use the bitfields of the split ip address and put that into a integer field. ie :

php Code:
Original - php Code
  1. <?//: {
  2.  
  3.     $ip = "202.45.75.112";
  4.  
  5.     $ipbin = ip2long($ip);
  6.     print("$ip = $ipbin<Br>");
  7.    
  8.     // Get it out again :
  9.     $ip = long2ip($ipbin);
  10.     print("$ip = $ipbin<br>");
  11. //;- }
  12. ?>


hehe, i was actually coding something that actually manipulates the bits.. and then i found the ip2long() and long2ip() functions

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Adding an IP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT