0

Hi
I have a database which has a table named main and a field named description
typ of description is longtext
I can insert more than 100 word through phpmyadmin. but can't insert through form submit by post method. but Here i can insert 10 word through same form submit.
Even I can use echo with that form field having 100 words but no data is inserting in database. what is the problem

Edited by arctushar: n/a

4
Contributors
9
Replies
10
Views
6 Years
Discussion Span
Last Post by FlashCreations
0

Limits are based on characters and not by words. Longtext allows for 4GB of characters, so in theory it depends on how long your words are. It is possible to have ten words that contain more characters than 100 words. But I doubt this is the case. Some possible limitations could be fontend scripts, backend trimming, and/or server limitations.
It would really help to see some code. As a rule, I would always post some relevant code unless your question involves theory.

0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  <title>Hello!</title>
</head>

<body>
<form name="insertitem" action="index.php" target="_self" method="post">
 Insert Serial <input type="text" name="serial" /> <p></p>

 Insert Description  <textarea name="description" cols="100" rows="10"></textarea> <p></p>
 Insert unit <input type="text" name="unit" /> <p></p>
 Insert price <input type="text" name="price" /> <p></p>
 <input type="submit" />
</form>
<?php
$description= $_POST['description'];
$con = mysql_connect("localhost","root","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("pwd", $con);

mysql_query("INSERT INTO shortitem (serial, description, unit, price)
VALUES ('$_POST[serial]', '$description','$_POST[unit]','$_POST[price]')");

mysql_close($con);
?>

</body>

</html>

my description input box value is Erect and remove semi-permanent engineer's site office (minimum 15 sqm plinth area) with required facilities including providing furniture, first-aid box, safety helmet, level/theodolite etc.
Erect and remove semi-permanent engineer's site office (minimum 38 sqm plinth area) with requied facilities including security fencing and providing furniture, first-aid box, safety helmet, level/theodolite facilities, 5-Kva stand-bye Generator etc.
Erect and remove semi-permanent Engineer's Site Office (minimum 38 sqm plinth area) with required facilities including providing furniture, first-aid box, safety helmet, level/theodolite facilities, 5-Kva stand-bye Generator etc.security fencing, PC with monitor, Laserjet Printer, UPS etc.
its not inserting but echo is ok

but when I submit Erect and remove semi-permanent engineer's site then it work well.

0

The problem is that you are not preparing the text for a SQL entry, so that apostrophe is editing the query that you are sending.

You can look up mysql_real_escape_string()[mysql recommended] or addslashes()[for non-specific databases] functions to resolve this issue.

Edited by Pirion1: n/a

0

The problem is that you are not preparing the text for a SQL entry, so that apostrophe is editing the query that you are sending.

You can look up mysql_real_escape_string()[mysql recommended] or addslashes()[for non-specific databases] functions to resolve this issue.

thank u sir. I m new in php. would u plz give me detail. I mean edited version of my above code.

0

mysql_real_escape_string() should be applied to any user generated content passed to MySQL to prevent SQL injections, but has no bearing on the limits on the text submitted (other than escaping characters).
The first thought that comes to mind is you aren't viewing the entire field. Try querying the DB, selecting the field, and outputting the description with PHP after inserting your description with your script. PhpMyAdmin never displays all the text if it exceeds a certain length. Usually you have to view the record individually to see the entire value of a long text field. When PhpMyAdmin truncates text, I believe it adds '...' after it to denote the truncation, but don't hold me to that.
Grab the description with PHP after inserting to verify, but I believe all the text will be there.

EDIT
Sample of using mysql_real_escape_string() to protect yourself from SQL injections, a dangerous hack that can expose and compromise data:

mysql_query("SELECT * FROM users WHERE username='".mysql_real_escape_string($_POST['username'])."' AND id='".mysql_real_escape_string($_POST['id')."'");

To grab the description, use the following:

//Conect to MySQL
//Then grab all the descriptions
$result = mysql_query("SELECT description FROM shortitem");
while($data = mysql_fetch_array($result)) {
echo $data['description']."<br>\n";
}

Edited by FlashCreations: n/a

0

Hi
I have a database which has a table named main and a field named description
typ of description is longtext
I can insert more than 100 word through phpmyadmin. but can't insert through form submit by post method. but Here i can insert 10 word through same form submit.
Even I can use echo with that form field having 100 words but no data is inserting in database. what is the problem

what form field are you using in the form to input data? please check if that field is not limited length or not...

Edited by Ezzaral: Snipped &quot;fake sig&quot; link. Please restrict personal links to your site-wide user signature, which can be edited from the user control panel.

0

Great! Please make sure to mark this thread as solved so other users know you don't require further assistance. Thanks :)

0

The limits are based on characters and not with words. LongText allows 4GB of characters, so in theory it depends on how long your words are. It is possible to have ten words that contain characters more than 100 words. But I doubt it is. Some possible restrictions could fontend backend script trimming and / or server limitations.

This sounds awfully familiar, almost like this was a post I wrote. In fact it is (the first post in this thread after the author's post).

"Limits are based on characters and not by words. Longtext allows for 4GB of characters, so in theory it depends on how long your words are. It is possible to have ten words that contain more characters than 100 words. But I doubt this is the case. Some possible limitations could be fontend scripts, backend trimming, and/or server limitations.
It would really help to see some code. As a rule, I would always post some relevant code unless your question involves theory."

Besides the thread is already solved, garryamin. Maybe you can contribute to another thread.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.