1--TEST-- 2mysqli_stmt_error() 3--SKIPIF-- 4<?php 5require_once('skipif.inc'); 6require_once('skipifemb.inc'); 7require_once('skipifconnectfailure.inc'); 8?> 9--FILE-- 10<?php 11 require_once("connect.inc"); 12 13 $tmp = NULL; 14 $link = NULL; 15 16 if (!is_null($tmp = @mysqli_stmt_error())) 17 printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); 18 19 if (!is_null($tmp = @mysqli_stmt_error($link))) 20 printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); 21 22 require('table.inc'); 23 24 if (!$stmt = mysqli_stmt_init($link)) 25 printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 26 27 // properly initialized? 28 if ('' !== ($tmp = mysqli_stmt_error($stmt))) 29 printf("[004] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); 30 31 if (mysqli_stmt_prepare($stmt, "SELECT i_do_not_exist_believe_me FROM test ORDER BY id")) 32 printf("[005] Statement should have failed!\n"); 33 34 // set after error server? 35 if ('' === ($tmp = mysqli_stmt_error($stmt))) 36 printf("[006] Expecting string/any non empty, got %s/%s\n", gettype($tmp), $tmp); 37 38 if (!mysqli_stmt_prepare($stmt, "SELECT id FROM test ORDER BY id")) 39 printf("[007] [%d] %s\n", mysqli_stmt_error($stmt), mysqli_stmt_error($stmt)); 40 41 // reset after error & success 42 if ('' !== ($tmp = mysqli_stmt_error($stmt))) 43 printf("[008] Expecting empty string, got %s/%s\n", gettype($tmp), $tmp); 44 45 mysqli_kill($link, mysqli_thread_id($link)); 46 47 if (true === ($tmp = mysqli_stmt_execute($stmt))) 48 printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); 49 50 // set after client error 51 if ('' === ($tmp = mysqli_stmt_error($stmt))) 52 printf("[010] Execting string/any non empty, got %s/%s\n", gettype($tmp), $tmp); 53 54 mysqli_stmt_close($stmt); 55 56 if (NULL !== ($tmp = mysqli_stmt_error($stmt))) 57 printf("[011] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); 58 59 mysqli_close($link); 60 print "done!"; 61?> 62--CLEAN-- 63<?php 64 require_once("clean_table.inc"); 65?> 66--EXPECTF-- 67Warning: mysqli_stmt_error(): Couldn't fetch mysqli_stmt in %s on line %d 68done!