2013-09-24 72 views
0

我收到錯誤消息,說「0行受到影響 警告:#1265當我將html保存到Mysql時,數據在第1行的'content'列被截斷數據庫。將HTML保存到MySQL警告:#1265數據被截斷列

的HTML是爲下:

關於我們
<p>We are revolutionising the way people shop around the world by providing the freedom to purchase from any website using your very own US or UK shipping address. We're used by both consumers and businesses to buy all sorts of products and merchandise from overseas. Have a look at what people are <a href="/pages/testimonials">saying</a> about us.</p> 
    <h2 class="title" id="title"> We<span class="green"> Offer</span> </h2> 
    <ul class="arr"> 
     <li>Great deals from all over the globe on a range of products from the hottest fashion to the latest technology.</li> 
     <li>Shipping rates designed with the consumer in mind!</li> 
     <li>Social Shipping- buy with friends and create one large package for Big Savings!</li> 
     <li>A clever Total Cost Calculator that allows you to see the Total Cost to deliver your package to your door- duties and taxes included!</li> 
    </ul> 
    <h2 class="title" id="title"> So who are<span class="green"> We</span> </h2> 
    <ul class="arr"> 
     <li><a href="/bx/enUS/pages/the-team">Check-out our team's profiles.</a></li> 
    </ul> 
    <h2 class="title" id="title"> Who uses <span class="green"> Store to Ship?</span> </h2> 
    <p>Store to Ship is used by private consumers and businesses to buy all sorts of products and merchandise overseas. Have a look at what people are saying about us.</p> 
+3

請分享您插入到HTML數據庫的代碼。 – Christoph

+1

你可以請張貼你的表格結構嗎? –

+0

可能會阻止查看您的表格結構。 –

回答

6

這是因爲要插入值的長度比列上定義的長度。增加列的長度。

+0

什麼應該準確長度?/ – Hunarman

+0

如果你不知道約大概的長度。使用類型作爲文本 –

0

使用Text DataType來存儲您的HTML代碼。

您的數據長度大於定義的長度。

CREATE TABLE IF NOT EXISTS menu (id int(11) NOT NULL AUTO_INCREMENT, menu_name varchar(255) NOT NULL, menu_url varchar(255) NOT NULL, content TEXT() NOT NULL, image varchar(255) NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ; 
1

我希望下面的解釋將幫助您

1. Use LONGTEXT/TEXT as type for the field in which you want to save html data 
2. 
    <?php 
    $data = "HTML data"; 

    if(get_magic_quotes_gpc()) 
     $data = trim($data); 
    else 
     $data = $mysqli->real_escape_string($data); 
    ?> 
3. then insert to this field. 
+0

謝謝大家的好建議 – Hunarman