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	mysqli_query($link, "set names utf8");
28
29	$tmp = mysqli_error($link);
30	if (!is_string($tmp) || ('' !== $tmp))
31		printf("[004] Expecting string/empty, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link));
32
33
34	mysqli_query($link, 'SELECT * FROM няма_такава_таблица');
35	$tmp = mysqli_error($link);
36	var_dump(str_replace($db.".", "", $tmp));
37
38	mysqli_close($link);
39
40	var_dump(mysqli_error($link));
41
42	print "done!";
43?>
44--EXPECTF--
45string(%d) "Table 'няма_такава_таблица' doesn't exist"
46
47Warning: mysqli_error(): Couldn't fetch mysqli in %s on line %d
48NULL
49done!
50