0
我有以下查詢工作正常:爲什麼我的簡單sql查詢不起作用?
SET @var := 'test';
INSERT INTO yi5vu_roksprocket_items (module_id, provider, params)
VALUES ('122', 'simple', @var)
但是,如果我改變變量如下面寫它不再起作用。
SET @var := '{"_article_title":"Simple Item 1","strips_item_title":"-none-","strips_item_image":"{'type':'mediamanager','path':'http:\/\/i.imgur.com\/fenrJmj.png','preview':'','link':'index.php?option=com_media&view=images&layout=default&tmpl=component&e_name=items_simple_1__params_strips_item_image'}","strips_item_link":"-default-","strips_item_description":"<html><body><div id=\"d_clip_button1\" class=\"btn btn-primary\" data-clipboard-text=\"[img]http:\/\/i.imgur.com\/fenrJmj.png[\/img]\" title=\"Copy.\"\">Copy<\/div> <script type=\"text\/javascript\" src=\"ZeroClipboard.js\"><\/script><script type=\"text\/javascript\"> var client = new ZeroClipboard(document.getElementById('d_clip_button1'));<\/script><\/body><\/html>","tabs_item_title":"-default-","tables_item_title":"-default-","lists_item_title":"-default-","mosaic_item_title":"-default-","grids_item_title":"-default-","quotes_item_description":"-default-","grids_item_description":"-default-","tables_item_description":"-default-","tabs_item_icon":"-default-","mosaic_item_description":"-default-","tabs_item_link":"-default-","lists_item_image":"-default-","quotes_item_image":"-default-","tables_item_image":"-default-","grids_item_image":"-default-","mosaic_item_image":"-default-","mosaic_item_link":"-default-","tabs_item_description":"-default-","grids_item_link":"-default-","tables_item_price":"-none-","tables_item_feature_1":"-none-","quotes_item_author":"-none-","lists_item_link":"-default-","mosaic_item_tags":"-article-","sliders_item_title":"-default-","features_item_title":"-default-","quotes_item_subtext":"-none-","tables_item_feature_2":"-none-","sliders_item_description":"-default-","headlines_item_image":"-default-","tables_item_feature_3":"-none-","lists_item_description":"-default-","quotes_item_link":"-default-","features_item_description":"-default-","quotes_item_direction":"-bottomleft-","features_item_image":"-default-","sliders_item_image":"-default-","headlines_item_link":"-default-","tables_item_feature_4":"-none-","tables_item_link":"-default-","features_item_link":"-default-","headlines_item_description":"-default-","sliders_item_link":"-default-","tables_item_link_text":"Buy Now"}';
INSERT INTO yi5vu_roksprocket_items (module_id, provider, params)
VALUES ('122', 'simple', @var)
是什麼導致了這個問題?我認爲這是單引號或後引號,但我嘗試了所有可能的組合。得到1064查詢錯誤。
我只是想採取@var裏面的內容並將它注入params。
請提供完整的錯誤描述 – 2015-02-10 20:20:50
可能是由於單引號轉義問題。您的字符串在「strips_item_image」之後結束:「{由於單引號'type' – 2015-02-10 20:21:34
可能是因爲單引號內有單引號,需要轉義它們 – 2015-02-10 20:21:52