jagguy Posted June 28, 2007 Share Posted June 28, 2007 I want the user to fill out a textbox and have that text upload to a webpage. Like a news announcement , the user can enter in what they want to say and then send and it appears underneath other text entries (using php/mysql). Now the problem is mysql seems to have a limit on what you can store , especially on the server that hosts my mysql (250 chars limit). I want 500-1000 words max so what can i do? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 28, 2007 Share Posted June 28, 2007 Use the BLOG or TEXT field type. Both of those can hold tons of characters. Your probably using a varchar field, the limit there is 255 chars. Quote Link to comment Share on other sites More sharing options...
Wuhtzu Posted June 28, 2007 Share Posted June 28, 2007 I can't imagine your mysql server (your hosting company's mysql server) has that kind of limits.... it must be your tables which aren't configured / created with the proper properties... You will mainly be using the following three field types: INT or INTEGER A normal-size integer The signed range is –2147483648 to 2147483647. The unsigned range is 0 to 4294967295 VARCHAR A variable-length string. Note: Trailing spaces are removed when the value is stored (this differs from the ANSI SQL specification) The range of Length is 1 to 255 characters. VARCHAR values are sorted and compared in case-insensitive fashion unless the BINARY keyword is given BLOB, TEXT A BLOB or TEXT column with a maximum length of 65535 (2^16 - 1) characters So my guess is that the field you use for storing your text is varchar set to 250 characters. Use TEXT or BLOB instead Quote Link to comment Share on other sites More sharing options...
redarrow Posted June 28, 2007 Share Posted June 28, 2007 use medium text on the database field or creating a whole book use long text. Quote Link to comment Share on other sites More sharing options...
jagguy Posted June 28, 2007 Author Share Posted June 28, 2007 I can't load a large amount of text as i get query failed but it works with say a few lines. Now i changed a varchar feld to longtext and didnt specifiy the length. It fails with this text and works if i truncate it to a few lines. "w to load a hard drive in fat32 (super user or root) su - /sbin/fdisk -l (to get the drive number /dev/sdb4 for my fat32 drive) in home dir or any dir mkdir mnt (remember the absolute path because you need to give this) mount -t vfat /dev/sdb4 /home/mnt extract .tar.gz tar -xvzf file.tar.gz hardware details - lsci -vv edit a file gedit filename etc. Let's say as a "for Error, query failed" html code here <form action="guestBook2.php" onsubmit="return validate()" method="post" > Please type your name<p> <input name="data1" id="data1" size="40" maxlength="80"> <p> Please type your email-address<p> <input name="data2" id="data2" size="40" maxlength="80"><br> <p><h4>Please type your comments (1000 words max.): </h4> <textarea name="data3" id="data3" rows="6" cols="40"></textarea><br><br> <input type="submit" value="Send"> </form></p> php $data1= $_POST['data1']; $data2 = $_POST['data2']; $data3= $_POST['data3']; echo "<h3>You typed in </h3><br><br> <strong>name :</strong>". $data1 . "<br><strong>email :</strong>" . $data2 . "<br> <strong>comments:</strong>" . $data3.""; $dbhost = 'localhost'; $conn = mysql_connect($dbhost,'root',' ') ; $dbname = 'formdata'; mysql_select_db($dbname); mysql_query( "INSERT INTO `personal` ( `id` , `name` , `email` , `comment2` , `date` ) VALUES ( NULL , '$data1', '$data2', '$data3',CURRENT_TIMESTAMP);") or die('Error, query failed'); Quote Link to comment Share on other sites More sharing options...
jagguy Posted June 28, 2007 Author Share Posted June 28, 2007 I found the problem as i has quotes in the text. If I remove them manually it works. How do i remove quotes from a string using php because this fails to remove quotes '' and "". $data3= $_POST['data3']; $data3=str_replace("''", "", $data3) ; $data3=str_replace("""", "", $data3) ; echo $data3;//has still got quotes in the text. Quote Link to comment Share on other sites More sharing options...
redarrow Posted June 28, 2007 Share Posted June 28, 2007 stripslashes(); http://uk3.php.net/stripslashes <?php $data3= $_POST['data3']; $data3=str_replace("''", " ", $data3) ; $data3=str_replace("""", " ", $data3) ; ?> Quote Link to comment Share on other sites More sharing options...
jagguy Posted June 28, 2007 Author Share Posted June 28, 2007 works $data3=(str_replace('"', '\\"', $data3)); $data3=(str_replace("'", "\\'", $data3)); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.