Jump to content

Max characters in a cell


BrianM

Recommended Posts

Depends on what you mean.

 

Restricting the input is one way - use maxlength=whatever in a text input

 

Echoing a sub-string of what's in your database is another.

 

If you could explain better what you're trying to achieve, you're likely to get more/better responses.

Well I'm trying to store a report submited from a <textarea></textarea> in a database with the fields -- ID, date, report -- the report field obviously containing the report submitted, which can be several paragraphs long. Well let's say I go to display the entire content of a cell under the report column so that the entire report submitted is output onto a web page that you may want to view later. Well it doesn't display the entire report on the output of the web page, only a limited amount of characters, so I'm not even sure the database is storing the entire report submitted, and maybe a limited amount of text.

 

So really, is what I'm getting at here, how do I store several paragraphs worth of text in a MySQL db cell under the report field, or any field for educational and future reference. Google and other web sites have been no help, nor have I have found any topic which relates to my subject. So I'm hoping I can get some help here.

 

Hope this is a bit more informative.

I was away on a little vacation.

 

Well I tried using 'text' as the field type and it doesn't let me insert even a paragraph worth of characters, but instead, just a few. Do you need anything like the table structure or the page code, would that help any?

Well now it's letting me insert a satisfying amount of text, but I notice when I add in thing's like apostrophes (') and other characters which aren't letter's or number's it wont insert my entry into the database and completely ignores it. How do I go about telling it to allow special characters like `~!@#$%^&*()-_=+[{]}\|;:'",<.>/? to be inserted into the database?

Here that is --

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>MPS - Create Report</title>
</head>
<?php
mysql_connect('localhost', 'brian', '*')
or die(mysql_error());
mysql_select_db('mps')
or die(mysql_error());

if (isset($_POST['report_submit'])) {
$sql = "INSERT INTO mps_reports (date, report) VALUES ('".$_POST['report_date']."', '".$_POST['report_text']."')";
$insert = mysql_query($sql);
}
?>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" name="report_date" value="<?php echo date("F j, Y"); ?>" />
<br />
<textarea name="report_text" cols="50" rows="8"></textarea>
<br />
<input type="submit" name="report_submit" value="Send" />
</form>
</body>
</html>

 

Would it also help to do something like, varchar(10000) - on the report field - since it allows letters, numbers and special characters? Of course replacing 10000 with something a little more suitable for what I need, being higher or lower.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.