[英]Delphi 2007 - I want to Read an .html file's content and then using ADO Insert or Update a SQL Server 2008 table with the HTML content
[英]MySQL 5 - Insert inline HTML content into SQL Column Failing using UPDATE
使用MySQL 5數據庫,我試圖使用內聯HTML手動更新數據庫中的字段,例如:
UPDATE employee SET bio = "<div style="text-align:center"> <H2>Employment History</H2> <table class='table' style="width:auto;margin-left:auto;margin-right:auto;"><tr><th>Year</th><th>Company</th></tr><tr><td>2013-14</td><td>IBM</td></tr><tr><td>2015-16</td><td>Microsoft</td></tr><tr><td>2016-17</td><td>Google</td></tr></table><H2>BIO</H2></div><p>John Smith started out as developer and became project manager.</p>" where ID = 100;
(順便說一句,這不是一行-當我在MySQL Shell中復制/粘貼它時,它被包裹成多行)
導致以下錯誤:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'margin-left:auto' at line 1
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'margin-right:auto' at line 1
我可能做錯了什么? 有沒有一種方法可以使用UPDATE或ALTER SQL語句中的HTML文件來進行此更改?
您在字符串周圍使用的引號與在字符串中HTML屬性使用的引號相同。 您需要使用不同的引號或對內部引號進行轉義。
UPDATE employee SET bio = "<div style='text-align:center'> <H2>Employment History</H2> <table class='table' style='width:auto;margin-left:auto;margin-right:auto;'><tr><th>Year</th><th>Company</th></tr><tr><td>2013-14</td><td>IBM</td></tr><tr><td>2015-16</td><td>Microsoft</td></tr><tr><td>2016-17</td><td>Google</td></tr></table><H2>BIO</H2></div><p>John Smith started out as developer and became project manager.</p>" where ID = 100;
如果使用客戶端應用程序語言來執行此操作,請使用准備好的語句,而不是直接替換為SQL字符串。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.