1--TEST-- 2mysql_list_fields() 3--SKIPIF-- 4<?php 5require_once 'skipif.inc'; 6require_once 'skipifconnectfailure.inc'; 7?> 8--FILE-- 9<?php 10require_once 'connect.inc'; 11 12$tmp = NULL; 13$link = NULL; 14 15require 'table.inc'; 16 17if (!$res = mysql_list_fields($db, 'test', $link)) 18 printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); 19 20if (2 !== ($num = mysql_num_fields($res))) 21 printf("[004] Expecting two fields from 'test', got %d. [%d] %s\n", $num, mysql_errno($link), mysql_error($link)); 22 23mysql_free_result($res); 24 25if (!mysql_query("DROP TABLE IF EXISTS test2", $link)) 26 printf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link)); 27 28if (!$res = @mysql_list_fields($db, 'test2', $link)) 29 printf("[006] [%d] %s\n", mysql_errno($link), mysql_error($link)); 30 31if (!$res = mysql_list_fields($db, 'test', $link)) 32 printf("[007] [%d] %s\n", mysql_errno($link), mysql_error($link)); 33 34if (2 !== ($num = mysql_num_fields($res))) 35 printf("[008] Expecting 2 fields from 'test', got %d. [%d] %s\n", $num, mysql_errno($link), mysql_error($link)); 36 37var_dump(mysql_fetch_assoc($res)); 38for ($field_offset = 0; $field_offset < mysql_num_fields($res); $field_offset++) { 39 printf("Field Offset %d\n", $field_offset); 40 printf("mysql_field_flags(): %s\n", mysql_field_flags($res, $field_offset)); 41 printf("mysql_field_len(): %s\n", mysql_field_len($res, $field_offset)); 42 printf("mysql_field_name(): %s\n", mysql_field_name($res, $field_offset)); 43 printf("mysql_field_type(): %s\n", mysql_field_type($res, $field_offset)); 44} 45 46mysql_free_result($res); 47mysql_close($link); 48 49print "done!"; 50?> 51--CLEAN-- 52<?php 53require_once 'connect.inc'; 54if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) 55 printf("[c001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", 56 $host, $user, $db, $port, $socket); 57 58if (!mysql_query("DROP TABLE IF EXISTS test", $link)) 59 printf("[c002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 60 61if (!mysql_query("DROP TABLE IF EXISTS test2", $link)) 62 printf("[c002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 63 64mysql_close($link); 65?> 66--EXPECTF-- 67[006] [%d] %s 68bool(false) 69Field Offset 0 70mysql_field_flags()%s 71mysql_field_len(): 11 72mysql_field_name(): id 73mysql_field_type(): int 74Field Offset 1 75mysql_field_flags()%s 76mysql_field_len(): 1 77mysql_field_name(): label 78mysql_field_type(): string 79done! 80