I want to store more than 1000 character in database, I use MySQL database.
When I insert 50-100 characters the code runs successfully. But when I insert 1000 characters it is not inserted. It also doesn’t gives an error.
When I use similar insert query in phpMyAdmin, the query runs successfully.
this is the query, first two fields are varchar & the last field is Longtext:
INSERT INTO news (headline,date,discription)
VALUES ("hi","date","A crumbling pitch and some resurgent Indian bowling have set up a gripping deciding Test with the series lead threatening to slip out of the hosts' grasp. India had snuck ahead at the end of the third day, but were dominant by lunch on the fourth as Pragyan Ojha and Amit Mishra ran through the Sri Lankan batting. Thilan Samaraweera, the centurion from the first innings, held firm and is key to Sri Lanka's fortunes as they try to build a lead that is competitive enough to give their spinners a chance. ")
This run successfully in phpMyAdmin
But when I try to run it in PHP, then it can’t run.
Here is the PHP code:
$insert = "INSERT INTO news (headline,date,discription)
VALUES ('".$_POST['headline']."','".$_POST['date5']."','".$_POST['discription']."')";
$add_news = mysql_query($insert);
& this code is use in tag
<textarea rows="2" cols="2" style="overflow: scroll; height: 90px; width: 635px;" name="discription"></textarea>
Use the
mysql_real_escape_stringfunction before your string variables eg:This could be most likely because the text contains single quotes which should be escaped.
Your code should look like this:
Note that addition of
or die(mysql_error()at the end, this would tell you if there is any error in the query itself.