Craig,

> I want to have users give a description in a form and varchar(255)
wont give
> me enough space so I thought I would use text(650) but it seems the
'text'
> type wont take the limit of (650), it simply offers the user (65535):
way
> too much.

In MySQL, you have TINYTEXT (2**8 = 256, like (VAR)CHAR), TEXT (2**16 =
65536), MEDIUMTEXT (2**24) and LONGTEXT (2**32). Unlike CHAR/VARCHAR,
you cannot restrict the length of TEXT column types.

Now for the good news: All TEXT types will store data dynamically, i.e.
let's say you store 10 bytes in a TEXT column, then this will require 12
bytes (2 bytes to store the actual length), not 65536 bytes.

If you want to restrict the amount of text your users can enter, you
will have to do this in your application. Just to point out what I mean,
here's a rather radical method using PHP:

$user_description = substr($user_description,0,650);
mysql_query("INSERT INTO userdata (description) VALUES
('$user_description')");

Alternatively, you could use:

mysql_query("INSERT INTO userdata (description) VALUES
(LEFT('$user_description',650))");

Regards,
--
  Stefan Hinz <[EMAIL PROTECTED]>
  Geschäftsführer / CEO iConnect GmbH <http://iConnect.de>
  Heesestr. 6, 12169 Berlin (Germany)
  Tel: +49 30 7970948-0  Fax: +49 30 7970948-3

----- Original Message -----
From: "Craig melia" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, January 21, 2003 6:27 PM
Subject: Whats between a varchar text ??


> Hi
>
> I am building my 1st app in php with Mysql and I hope you can help.
>
> I want to have users give a description in a form and varchar(255)
wont give
> me enough space so I thought I would use text(650) but it seems the
'text'
> type wont take the limit of (650), it simply offers the user (65535):
way
> too much.
>
> Is there anything I can do to set a column type to recieve just 650
> characters of text, or something similar?
>
> Craig
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
>


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to