1--TEST-- 2mysqli_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_error())) 17 printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); 18 19 if (!is_null($tmp = @mysqli_error($link))) 20 printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); 21 22 if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { 23 printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", 24 $host, $user, $db, $port, $socket); 25 } 26 27 if (!(version_compare(PHP_VERSION, '6.0', '==') == 1)) { 28 mysqli_query($link, "set names utf8"); 29 } 30 31 $tmp = mysqli_error($link); 32 if (!is_string($tmp) || ('' !== $tmp)) 33 printf("[004] Expecting string/empty, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); 34 35 36 mysqli_query($link, 'SELECT * FROM няма_такава_таблица'); 37 $tmp = mysqli_error($link); 38 var_dump(str_replace($db.".", "", $tmp)); 39 40 mysqli_close($link); 41 42 var_dump(mysqli_error($link)); 43 44 print "done!"; 45?> 46--EXPECTF-- 47%unicode|string%(%d) "Table 'няма_такава_таблица' doesn't exist" 48 49Warning: mysqli_error(): Couldn't fetch mysqli in %s on line %d 50NULL 51done!