English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

PHP odbc_field_len() Function Usage and Example

PHP ODBC Reference Manual

The odbc_field_len() function retrieves the length (precision) of the field

Syntax

int odbc_field_len ( resource $result_id, int $field_number )

Definition and Usage

It is used to get the length of a field

Return Value

Returns the field length, returns False if an error occurs.

Parameter

NumberParameters and Description
1

result_id

Result Identifier.

2

field_number

Field Number. The field number starts from1Start.

Example

Try the following example

<?php
   $input_ID = odbc_connect("DSN", "user_id", "pass_id");
   $sql = "SELECT * FROM Products";
   $result = odbc_exec($input_ID, $sql);
   
   odbc_fetch_row($result);
   
   for ($col = 1; $col <= odbc_num_fields($result); $col++) {
      printf("Column %s has length %s\n", odbc_field_name($result, $col), odbc_field_len($result, $col));
   }
?>

PHP ODBC Reference Manual