Re: Whats between a varchar text ??

2003-01-21 Thread Stefan Hinz, iConnect \(Berlin\)
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 
  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




Re: Whats between a varchar text ??

2003-01-21 Thread Keith C. Ivey
On 21 Jan 2003, at 17:27, Craig melia wrote:

> 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.

Use a TEXT column and limit the length of the input in your 
application, which you probably should be doing anyway (since just 
having MySQL truncate it without notifying the user wouldn't be very 
friendly).

[Filter fodder: SQL]

-- 
Keith C. Ivey <[EMAIL PROTECTED]>
Tobacco Documents Online
http://tobaccodocuments.org
Phone 202-667-6653

-
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




Re: Whats between a varchar text ??

2003-01-21 Thread Paul DuBois
At 17:27 + 1/21/03, Craig melia wrote:

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.


Why does this matter?  MySQL doesn't store 65535 characters per value,
just the characters that are actually in your string.  The column uses
only as much space as is necessary.

You can easily enforce a limit of 650 characters in your application.



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




RE: Whats between a varchar text ??

2003-01-21 Thread Chris Faust
If you want to limit the amount of text coming in or going out, wouldn't it
be easier to it either in your php script or constrain the html textarea?

Just a thought.

-Chris


>> -Original Message-
>> From: Craig melia [mailto:[EMAIL PROTECTED]]
>> Sent: Tuesday, January 21, 2003 12:28 PM
>> To: [EMAIL PROTECTED]
>> 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