NodeReaper has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: mysql...
by Kanji (Parson) on Feb 09, 2002 at 16:18 UTC
(jeffa) Re: mysql...
by jeffa (Bishop) on Feb 09, 2002 at 16:16 UTC
    This is a database question - since you are using mysql you can issue 'desc table' to see what the fields are and how many chars they can hold (after the table is created, of course).

    If you are wanting to 'truncate' a string before inserting it into a database, then use substr:

    my $field = 'big long string...'; $field = substr($field,0,255); # or a regex (slower of course) $field =~ s/^(.{255}).*$/$1/;
    Hope this helps,

    jeffa

    'Hey, i _tried_ to turn this into a Perl question ;)'
Re: mysql...
by andye (Curate) on Feb 09, 2002 at 18:32 UTC
Re: mysql...
by Parham (Friar) on Feb 09, 2002 at 23:23 UTC
    you can specify your column types to be several lengths: if you use CHAR().. you can have a maximum of 255 characters (1-255, you specify)

    with CHAR(num) you can specify a number of max characters, up to 255... if you make you column type TINYBLOB or TINYTEXT, you can have anywhere from 1-255 (2^5 - 1). BLOB or TEXT types have a maximum of 65535 (2^16 - 1) characters. MEDIUMBLOB or MEDIUMTEXT columns have a maximum length of 4294967295 (2^32 - 1) characters. LONGBLOB or LONGTEXT have a maximum length of 4294967295 (2^32 - 1) characters.

    those are just some of the column types. The more specific you make your colums, the more control you have over your database, and the input you get from users. For a better list.. go here