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