Jump to content

mcrypt string storage issue.


PHPGeek80

Recommended Posts

Hi,

 

I have an mcrypt function that encrypts a string for storage into a mysql database.

 

The problem i have is that when im inserting encrypted data, sometimes the encrypted strings include one or more single quotes which is what i due to split the individual fields.

 

e.g.

 

INSERT INTO `tbl` VALUES (0, 'ljoihop', '768', 'bu'ut', 'higuyvgcvyt', '76687t87', 'OIUOIHIUGG');

 

As you can see the 4th field "bu'ut" has a single quote within the string.

 

I just checked and it doesnt work with double quotes either.

 

How can i get around this?

Link to comment
https://forums.phpfreaks.com/topic/39806-mcrypt-string-storage-issue/
Share on other sites

You need to process all text that you plan to store in the data base through the function mysql_real_escape_string().

 

<?php
$ v = mysql_real_escape_string("John's");
$q = "NSERT INTO `tbl` VALUES (0, 'Happy', 'Sad', '$v', 'Mick', '1', '18');
?>

 

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.