sseeley Posted February 28, 2009 Share Posted February 28, 2009 I am trying to insert an encrypted line into MYSQL. However each time I try I get an error. I am using $updateDataRow=mysql_query(" UPDATE tbluser SET `firstName` = '$encryptedFirstName' "); However the encrypted string contains a ' therefore I am getting the following error : 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'N(« íwÊ픦÷Ýøª<"˜©ÙÀ'' at line 1' The encryped string is as follows... '™–w> ‚©'N(« íwÊ픦÷Ýøª<"˜©ÙÀ' Can anyone help me? Many thanks in advance. Stuart Link to comment https://forums.phpfreaks.com/topic/147290-solved-encryption-insert/ Share on other sites More sharing options...
waynew Posted February 28, 2009 Share Posted February 28, 2009 $encryptedFirstName = mysql_real_escape_string($encryptedFirstName); $updateDataRow=mysql_query(" UPDATE tbluser SET `firstName` = '$encryptedFirstName' ") or trigger_error(mysql_error()); Escape characters such as ' by using mysql_real_escape_string, which makes it safe for insertion. Link to comment https://forums.phpfreaks.com/topic/147290-solved-encryption-insert/#findComment-773176 Share on other sites More sharing options...
Mark Baker Posted February 28, 2009 Share Posted February 28, 2009 And make sure that your firstname column is of a datatype that accepts binary data rather than simply VARCHAR, otherwise you'll need to convert $encryptedFirstName to ASCII data as well before you store it. Link to comment https://forums.phpfreaks.com/topic/147290-solved-encryption-insert/#findComment-773187 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.