mysql_field_len Problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rbutlerjr@gmail.com

    mysql_field_len Problem

    I've run into a strange problem with mysql_field_len returning -1 on
    any / all calls to it. This is on an Unbuntu Dapper system, with PHP
    4.4.2, MySQL 4.1.15, and the PHP/MySQL Client API is 5.0.18. This is
    using the default dpkg installs of php4-mysql and mysql-server-4.1
    This same call and associated code works properly on existing Windows
    and Linux systems (both with older versions of PHP & MySQL). The
    primary difference that I can see is those systems are using API
    3.23.49.
    I'm barely a linux novice (much less intermediate level), so I'm not
    sure how to go about changing the API version. Any help would be
    appreciated.

  • Michael Austin

    #2
    Re: mysql_field_len Problem

    rbutlerjr@gmail .com wrote:
    [color=blue]
    > I've run into a strange problem with mysql_field_len returning -1 on
    > any / all calls to it. This is on an Unbuntu Dapper system, with PHP
    > 4.4.2, MySQL 4.1.15, and the PHP/MySQL Client API is 5.0.18. This is
    > using the default dpkg installs of php4-mysql and mysql-server-4.1
    > This same call and associated code works properly on existing Windows
    > and Linux systems (both with older versions of PHP & MySQL). The
    > primary difference that I can see is those systems are using API
    > 3.23.49.
    > I'm barely a linux novice (much less intermediate level), so I'm not
    > sure how to go about changing the API version. Any help would be
    > appreciated.
    >[/color]

    can we see the code line where you are trying to use this? and are you using it
    properly?

    From the docs:
    Example 1. A mysql_fetch_len () example
    <?php
    $result = mysql_query("SE LECT id,email FROM people WHERE id = '42'");
    if (!$result) {
    echo 'Could not run query: ' . mysql_error();
    exit;
    }

    // Will get the length of the value in email so for example
    // user@example.co m would give us a length of 16
    $length = mysql_fetch_len ($result, 'email');
    echo $length;
    ?>


    --
    Michael Austin.
    DBA Consultant
    Donations welcomed. Http://www.firstdbasource.com/donations.html
    :)

    Comment

    • rbutlerjr@gmail.com

      #3
      Re: mysql_field_len Problem

      Sure:

      function returnColumnSiz e ($column) {
      $db_connection = connect ();
      $query = "SELECT $column FROM $this->tablename LIMIT 1";
      $result = mysql_query ($query, $db_connection) ;
      if (!$result) {
      die ("Invalid Database Query ($query): " . mysql_error() );
      } else {
      return (mysql_field_le n ($result, 0));
      }
      // We had data, but couldn't find the column_name specified.
      return FALSE;
      }

      This continues to work perfectly fine on my other three systems (2
      windows, 1 ISP linux), but fails on this Ubuntu.

      Comment

      • rbutlerjr@gmail.com

        #4
        Re: mysql_field_len Problem

        OK, I've played around with it a bit more, and it appears that
        mysql_field_len returns -1 when looking at a longtext column, not other
        types... Blob, text, ints, mediumtext, etc work fine.
        Still not sure why this is affecting this particular machine.

        Comment

        Working...