mysql_field_len Problem

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
  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
  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

Re: mysql_field_len Problem wrote:

Quoted text here. Click to load it

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

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

// Will get the length of the value in email so for example
// would give us a length of 16
$length = mysql_fetch_len($result, 'email');
echo $length;

Michael Austin.
DBA Consultant
Donations welcomed. Http://

Re: mysql_field_len Problem


function returnColumnSize ($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_len ($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.

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.

Site Timeline