Announcement

Collapse
No announcement yet.

"&" char within of a ID can make some strange behaviors in SELECT ?

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

  • "&" char within of a ID can make some strange behaviors in SELECT ?

    I got a super standard select on a field ID (CategoryID) but I got a problem with some ID containing special chars.

    SELECT CategoryID, Descrizione_Web
    FROM categories
    WHERE CategoryID = '{CategoryID}'
    ORDER BY Descrizione_Web

    In my case the ID is "PCBG_C&C".
    Due to the fact that only where there is & there are problems I suppose that it's not possible.

    How can I modify the SELECT to read all the ID with also the & inside ?? Now it seems that it try to read PCBG_C and then it do not find the category description.

    Thanks
    Last edited by giovannino; 11-19-2015, 01:50 PM.

  • #2
    You could try to use the addslashes php function to escape the characters.
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment


    • #3
      Hello Albert,
      thanks, just to understand...
      may I add the adslashes within the mysql query ?

      WHERE CategoryID = adslashes( '{CategoryID}' )

      I don't think that is possible ..

      Comment


      • #4
        No, you need to put this in the onvalidate event, or in the beforeinsert/update.
        {myfield}=addslashes({myfield})
        Albert Drent
        aducom software netherlands
        scriptcase partner, reseller, support and (turn-key) development
        www.scriptcase.eu / www.scriptcase.nl

        Comment


        • #5
          OK . Many thanks. I'll try

          Comment

          Working...
          X