1--TEST--
2mysqli_error()
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7?>
8--FILE--
9<?php
10    require_once("connect.inc");
11
12    if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
13        printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
14            $host, $user, $db, $port, $socket);
15    }
16
17    mysqli_query($link, "set names utf8");
18
19    $tmp = mysqli_error($link);
20    if (!is_string($tmp) || ('' !== $tmp))
21        printf("[004] Expecting string/empty, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link));
22
23
24    mysqli_query($link, 'SELECT * FROM няма_такава_таблица');
25    $tmp = mysqli_error($link);
26    var_dump(str_replace($db.".", "", $tmp));
27
28    mysqli_close($link);
29
30    try {
31        mysqli_error($link);
32    } catch (Error $exception) {
33        echo $exception->getMessage() . "\n";
34    }
35
36    print "done!";
37?>
38--EXPECTF--
39string(%d) "Table 'няма_такава_таблица' doesn't exist"
40mysqli object is already closed
41done!
42