2013-09-24 52 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