Jump to content

Recommended Posts

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

  • 2 months later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.