Announcement

Collapse
No announcement yet.

[SOLVED] Problem with single quote ' (quotation mark) string in the text field.

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • [SOLVED] Problem with single quote ' (quotation mark) string in the text field.

    I am facing a problem when my user enter a quotation mark (') in some of the text fields. I am using MSSQL Server Native SRV. In VB6, I know that every time when we need to save any data with a ', we need to write a small function to convert that to '' in order for the data to be saved.

    I have a field called comments in my project. The user sometimes will type in something like "Assigned to Henry's department" Whenever there is a single quote ' mark in the field, scriptcase will prompt out error :

    Error updating database -
    SQLState: 42000 Error Code: 102 Message: [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near 'KK'. SQLState: 42000 Error Code: 105 Message: [Microsoft][SQL Server Native Client 10.0][SQL Server]Unclosed quotation mark after the character string ' '. S

    Help would be greatly appreciated.

    GT

  • #2
    Hi. I think maybe all you need to do is use this php command: http://www.w3schools.com/php/func_my...ape_string.asp
    That has some good examples.
    Peace,
    Jamie

    Comment


    • #3
      AFAIK this is for MySQL only. The problem here is SQL Server. But the approach would be similar I guess.
      Albert Drent
      aducom software netherlands
      scriptcase partner, reseller, support and (turn-key) development
      www.scriptcase.eu / www.scriptcase.nl

      Comment


      • #4
        I resolved it using str_replace as follow:

        {Description}=str_replace("'", "''", {Description});

        at the onbeforeinsert and onbeforeupdate events

        Thanks all!

        GT

        Comment

        Working...
        X