CodeIgniter Forums
Dealing with binary values in Mysql DB - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Dealing with binary values in Mysql DB (/showthread.php?tid=69236)



Dealing with binary values in Mysql DB - neuron - 10-23-2017

Hi,

I store IP's in binary format;
PHP Code:
$ip inet_pton($_SERVER['REMOTE_ADDR']); //binary value 
and in DB query I do this way:

PHP Code:
$sql "SELECT MAX(attempted_at) as last_failed_attempt
    FROM failed_login
    WHERE attempted_at > DATE_SUB('
$now', INTERVAL $delay_minutes MINUTE)
    AND ip_address = " 
$this->db->escape($ip); 


My issue is for eacmaple when I echo binary $ip  it contained this value •Œ'þ   it contains single quotation mark. 
and after running this $this->db->escape($ip) this outputs '•Œ\'þ' so is the binary field changed when I run this $this->db->escape() function. 
am I doing query right way? Or is there other way to do queries for for binary values?


RE: Dealing with binary values in Mysql DB - InsiteFX - 10-24-2017

You might want to take a look at this, should help you out.

Virtual Secrets - Project mySQL + IP