how to insert ip address in mysql using php

Solutions on MaxInterview for how to insert ip address in mysql using php by the best coders in the world

showing results for - "how to insert ip address in mysql using php"
Jenna
26 Aug 2016
1-- `ip_address` int(4) unsigned NOT NULL
2INSERT INTO my_table (`ip_address`) VALUES (INET_ATON("127.0.0.1"));
3SELECT INET_NTOA(ip_address) as ip FROM my_table;
4-- php
5<?php
6var_dump(ip2long('123.63.153.253'));	-- 2067765757
7var_dump(long2ip(2067765757));			-- "123.63.153.253"
8?>
Julieta
07 Jan 2021
1-- `ip_address` int(4) unsigned NOT NULL
2INSERT INTO my_table (`ip_address`) VALUES (INET_ATON("127.0.0.1"));
3SELECT INET_NTOA(ip_address) as ip FROM my_table;
4-- php
5<?php
6$ipaddress = $_SERVER['REMOTE_ADDR'];  
7var_dump(ip2long('123.63.153.253'));	-- 2067765757
8var_dump(long2ip(2067765757));			-- "123.63.153.253"
9?>