PHPGeek80 Posted February 23, 2007 Share Posted February 23, 2007 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 More sharing options...
kenrbnsn Posted February 23, 2007 Share Posted February 23, 2007 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 Link to comment https://forums.phpfreaks.com/topic/39806-mcrypt-string-storage-issue/#findComment-192257 Share on other sites More sharing options...
PHPGeek80 Posted February 23, 2007 Author Share Posted February 23, 2007 thank you kenrbnsn. Thats worked great. Link to comment https://forums.phpfreaks.com/topic/39806-mcrypt-string-storage-issue/#findComment-192270 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.