1--TEST--
2$mysqli->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    $mysqli = new mysqli();
17    if ('' !== ($tmp = @$mysqli->error))
18        printf("[001] Expecting empty string, got %s/'%s'\n", gettype($tmp), $tmp);
19
20    if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
21        printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
22            $host, $user, $db, $port, $socket);
23
24    $tmp = $mysqli->error;
25    if (!is_string($tmp) || ('' !== $tmp))
26        printf("[003] Expecting string/empty, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, $mysqli->errno, $mysqli->error);
27
28    if (!$mysqli->query('DROP TABLE IF EXISTS test')) {
29        printf("[004] Failed to drop old test table: [%d] %s\n", $mysqli->errno, $mysqli->error);
30    }
31
32    $mysqli->query('SELECT * FROM test');
33    $tmp = $mysqli->error;
34    if (!is_string($tmp) || !preg_match("/Table '\w*\.test' doesn't exist/su", $tmp))
35        printf("[006] Expecting string/[Table... doesn't exit], got %s/%s. [%d] %s\n", gettype($tmp), $tmp, $mysqli->errno, $mysqli->error);
36
37    $mysqli->close();
38
39    var_dump($mysqli->error);
40
41    print "done!";
42?>
43--EXPECTF--
44Warning: main(): Couldn't fetch mysqli in %s on line %d
45bool(false)
46done!
47