0

I am getting error message saying "0 rows affected. Warning: #1265 Data truncated for column 'content' at row 1" when i am saving my html to Mysql database.

The Html is as under:

About Us
    <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>
Jenson M John
  • 5,499
  • 5
  • 30
  • 46
Hunarman
  • 49
  • 1
  • 2
  • 7

3 Answers3

6

It's because the length of the value you are inserting is greater than the length defined on the column. Increase the length of your column.

Jenson M John
  • 5,499
  • 5
  • 30
  • 46
1

I hope following explanation will help you

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.
MD SHAHIDUL ISLAM
  • 14,325
  • 6
  • 82
  • 89
0

Use Text DataType to store your HTML code in it.

Your length of data is greater than the defined length .

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 ;
Sumit Bijvani
  • 8,154
  • 17
  • 50
  • 82