Search
 
SCRIPT & CODE EXAMPLE
 

SQL

how to insert ip address in mysql using php

-- `ip_address` int(4) unsigned NOT NULL
INSERT INTO my_table (`ip_address`) VALUES (INET_ATON("127.0.0.1"));
SELECT INET_NTOA(ip_address) as ip FROM my_table;
-- php
<?php
var_dump(ip2long('123.63.153.253'));	-- 2067765757
var_dump(long2ip(2067765757));			-- "123.63.153.253"
?>
Comment

how to insert ip address in mysql using php

-- `ip_address` int(4) unsigned NOT NULL
INSERT INTO my_table (`ip_address`) VALUES (INET_ATON("127.0.0.1"));
SELECT INET_NTOA(ip_address) as ip FROM my_table;
-- php
<?php
$ipaddress = $_SERVER['REMOTE_ADDR'];  
var_dump(ip2long('123.63.153.253'));	-- 2067765757
var_dump(long2ip(2067765757));			-- "123.63.153.253"
?>
Comment

PREVIOUS NEXT
Code Example
Sql :: vowels in sql 
Sql :: mysql to get column name in database 
Sql :: check postgresql version in rails console 
Sql :: mysql date range 
Sql :: check if sql is installed 
Sql :: mysql alter add foreign key 
Sql :: referential integrity constraint 
Sql :: mysql select into new table 
Sql :: delete all value query 
Sql :: oracle get running queries 
Sql :: connexion mysql 
Sql :: oracle apex warning message 
Sql :: postgres regular expression replace 
Sql :: check if value is equal to something sql 
Sql :: oracle percentage 
Sql :: how to insert multiple rows in sql 
Sql :: How to add a Try/Catch to SQL Stored Procedure 
Sql :: SQL ORDER BY DESC (Descending Order) 
Sql :: show database cmd 
Sql :: wherein sql 
Sql :: get primary key of last inserted record sql server 
Sql :: count in sql and diff 
Sql :: truncate all tables 
Sql :: mysql run sql file 
Sql :: how to set a column as unique in sql server 
Sql :: get all columns in a table sql 
Sql :: sql server drop column 
Sql :: sqlserver add column 
Sql :: postgres week number 
Sql :: find number of entries sql 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =