Results 1 to 7 of 7

Thread: add " to sql querry

  1. #1
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default add " to sql querry

    i want to insert quotes into my dB table like:

    Code:
     UPDATE $priceTable SET width=36" WHERE item LIKE 'greyItem';
    but the " after 36 is throwing an error, how can i do this?

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Pretty sure you need to escape it like this
    Code:
     UPDATE $priceTable SET width=36\" WHERE item LIKE 'greyItem';
    Corrections to my coding/thoughts welcome.

  3. #3
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default

    hmm, get this error
    There seems to be an error in your SQL query. The MySQL server error output below, if there is any, may also help you in diagnosing the problem

    ERROR: Unclosed quote @ 33
    STR: "

  4. #4
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Oo, okay. Is width set as an integer or varchar(something non-integered)?

    If it's an integer I don't think it can take the value with anything but numerals in it.

    If it's varchar try

    Code:
    UPDATE $priceTable SET width='36"' WHERE item LIKE 'greyItem';
    If your putting this into php and that is enclosed in double quotes you'll need to escaped the double quote
    PHP Code:
    $query "UPDATE $priceTable SET width='36\"' WHERE item LIKE 'greyItem'"
    Corrections to my coding/thoughts welcome.

  5. #5
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default

    weird, i get an error when i wrap it in single quotes

    Code:
    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax

    it is varchar

  6. #6
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    It could be the like throwing it off as well

    Code:
    UPDATE $priceTable SET width='36"' WHERE item = 'greyItem';
    or

    Code:
    UPDATE $priceTable SET width='36"' WHERE item LIKE '%greyItem%';
    If this isn't being called in php I think the $priceTable will cause it to fail unless you set it as a variable. If this doesn't fix it please post how you are using it, the statement being used, and the message you receive.
    Corrections to my coding/thoughts welcome.

  7. #7
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default

    weird, when i do
    Code:
    UPDATE $priceTable SET repeat='NON-WOVEN' WHERE descript_1 LIKE 'Ori';
    i get an error

    you can see that this dB is varchar

    and that it can be accessed by select

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •