#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Location
    Aalborg, Denmark
    Posts
    36
    Rep Power
    15
    Hi

    I'm writing a generel function for one of my sites.

    In that function i need to be able to retrieve the lenght of a MySQL field.
    eg. if the field is declared with MyName = VARCHAR(50) i need to parse the 50.
    I use PHP (3) as front-end and i'm retrieving data as follows:
    $mrQuery = db_query("SELECT fieldValue FROM ".$my_table_name." WHERE fieldName = ".$my_field_name."");

    What do i need to do to get the length of "fieldValue"??

    Regards

    // Martin

    [This message has been edited by kaasgaard (edited May 27, 2000).]
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    You'll have to use the mysql_list_fields() function as the query:

    $result=mysql_list_fields("databasename","tablename");

    and mysql_field_len() to get the length:

    $len=mysql_field_len($result,$field_num);

    where $field_num is the offset of the field you wish to retrieve.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Location
    Aalborg, Denmark
    Posts
    36
    Rep Power
    15
    Works like a charm

    Thanx.

    // Martin

    [This message has been edited by kaasgaard (edited May 27, 2000).]

Similar Threads

  1. form field length validation
    By friendly_state in forum ASP Programming
    Replies: 2
    Last Post: August 12th, 2003, 03:15 PM
  2. finding the length of values in a key field
    By EAD in forum MySQL Help
    Replies: 2
    Last Post: December 6th, 2002, 03:34 AM
  3. setting blob field length
    By pzaz in forum MySQL Help
    Replies: 1
    Last Post: August 13th, 2002, 02:20 AM
  4. Can I get the average length of a field?
    By beetrader in forum Database Management
    Replies: 4
    Last Post: July 9th, 2002, 02:41 AM
  5. Database design question
    By mcsimon in forum Dev Shed Lounge
    Replies: 2
    Last Post: August 5th, 2001, 01:17 AM

IMN logo majestic logo threadwatch logo seochat tools logo