View Full Version : add " to sql querry
ggalan
09-09-2010, 05:29 PM
i want to insert quotes into my dB table like:
UPDATE $priceTable SET width=36" WHERE item LIKE 'greyItem';
but the " after 36 is throwing an error, how can i do this?
bluewalrus
09-09-2010, 05:43 PM
Pretty sure you need to escape it like this
UPDATE $priceTable SET width=36\" WHERE item LIKE 'greyItem';
ggalan
09-09-2010, 05:53 PM
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: "
bluewalrus
09-09-2010, 05:57 PM
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
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
$query = "UPDATE $priceTable SET width='36\"' WHERE item LIKE 'greyItem'";
ggalan
09-09-2010, 06:11 PM
weird, i get an error when i wrap it in single quotes
#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
bluewalrus
09-09-2010, 06:55 PM
It could be the like throwing it off as well
UPDATE $priceTable SET width='36"' WHERE item = 'greyItem';
or
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.
ggalan
09-09-2010, 09:36 PM
weird, when i do
UPDATE $priceTable SET repeat='NON-WOVEN' WHERE descript_1 LIKE 'Ori';
i get an error
http://www.2020proj.com/media/images/sql/Capture2.JPG
you can see that this dB is varchar
http://www.2020proj.com/media/images/sql/Capture.JPG
and that it can be accessed by select
http://www.2020proj.com/media/images/sql/Capture3.JPG
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.