grantf Posted March 1, 2008 Share Posted March 1, 2008 Hi, i have successfullly put together some code that writes form data to my mssql db however during testing, if the form field contains an apostrephe the query fails. how do you get around this? this is the query line i am using.. $reason = $_POST['reason']; $update = "INSERT INTO journals(reason) VALUES ('$reason')"; mssql_query($update, $link); .. the form field might contain something like this, the cat's sat on the mat this is the error.. PHP Warning: mssql_query() [function.mssql-query]: message: Incorrect syntax near 's'. (severity 15) in C:\Inetpub\wwwroot\forms\journal-send.php on line 71 PHP Warning: mssql_query() [function.mssql-query]: message: Unclosed quotation mark after the character string ');'. (severity 15) in C:\Inetpub\wwwroot\forms\journal-send.php on line 71 PHP Warning: mssql_query() [function.mssql-query]: Query failed in C:\Inetpub\wwwroot\forms\journal-send.php on line 71 Quote Link to comment https://forums.phpfreaks.com/topic/93909-insert-query-with-values-containing-apostrephe/ Share on other sites More sharing options...
gnawz Posted May 14, 2008 Share Posted May 14, 2008 You have to play around with the quotes.. Change " for ' and have consistency with them Quote Link to comment https://forums.phpfreaks.com/topic/93909-insert-query-with-values-containing-apostrephe/#findComment-540726 Share on other sites More sharing options...
matudustrauss Posted May 16, 2008 Share Posted May 16, 2008 Try removing the '' Quote Link to comment https://forums.phpfreaks.com/topic/93909-insert-query-with-values-containing-apostrephe/#findComment-542777 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.