1--TEST-- 2mysql_field_len() 3--SKIPIF-- 4<?php 5require_once('skipif.inc'); 6require_once('skipifconnectfailure.inc'); 7?> 8--FILE-- 9<?php 10include "connect.inc"; 11 12$tmp = NULL; 13$link = NULL; 14 15if (!is_null($tmp = @mysql_field_len())) 16 printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); 17 18if (null !== ($tmp = @mysql_field_len($link))) 19 printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); 20 21require('table.inc'); 22if (!$res = mysql_query("SELECT id, label FROM test ORDER BY id LIMIT 2", $link)) { 23 printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); 24} 25 26if (NULL !== ($tmp = mysql_field_len($res))) 27printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); 28 29if (false !== ($tmp = mysql_field_len($res, -1))) 30 printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); 31 32if (!is_int($tmp = mysql_field_len($res, 0)) || empty($tmp)) 33 printf("[006] Expecting non empty integer, got %s/%s\n", gettype($tmp), $tmp); 34 35if (false !== ($tmp = mysql_field_len($res, 2))) 36 printf("[008] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); 37 38mysql_free_result($res); 39 40var_dump(mysql_field_len($res, 0)); 41 42mysql_close($link); 43print "done!"; 44?> 45--CLEAN-- 46<?php 47require_once("clean_table.inc"); 48?> 49--EXPECTF-- 50Warning: mysql_field_len() expects exactly 2 parameters, 1 given in %s on line %d 51 52Warning: mysql_field_len(): Field -1 is invalid for MySQL result index %d in %s on line %d 53 54Warning: mysql_field_len(): Field 2 is invalid for MySQL result index %d in %s on line %d 55 56Warning: mysql_field_len(): %d is not a valid MySQL result resource in %s on line %d 57bool(false) 58done! 59