1--TEST--
2mysqli_free_result()
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_free_result()))
17		printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
18
19	if (!is_null($tmp = @mysqli_free_result($link)))
20		printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
21
22	require('table.inc');
23	if (!$res = mysqli_query($link, "SELECT id FROM test ORDER BY id LIMIT 1")) {
24		printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
25	}
26
27	print "a\n";
28	var_dump(mysqli_free_result($res));
29	print "b\n";
30	var_dump(mysqli_free_result($res));
31
32	if (!$res = mysqli_query($link, "SELECT id FROM test ORDER BY id LIMIT 1")) {
33		printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
34	}
35	print "c\n";
36	var_dump($res = mysqli_store_result($link));
37	var_dump(mysqli_error($link));
38	print "[005]\n";
39	var_dump(mysqli_free_result($res));
40
41	if (!$res = mysqli_query($link, "SELECT id FROM test ORDER BY id LIMIT 1")) {
42		printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
43	}
44	print "d\n";
45	var_dump($res = mysqli_use_result($link));
46	var_dump(mysqli_error($link));
47	print "[007]\n";
48	var_dump(mysqli_free_result($res));
49
50	mysqli_close($link);
51	print "done!";
52?>
53--CLEAN--
54<?php
55	require_once("clean_table.inc");
56?>
57--EXPECTF--
58a
59NULL
60b
61
62Warning: mysqli_free_result(): Couldn't fetch mysqli_result in %s on line %d
63NULL
64c
65bool(false)
66%s(0) ""
67[005]
68
69Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in %s on line %d
70NULL
71d
72bool(false)
73%s(0) ""
74[007]
75
76Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in %s on line %d
77NULL
78done!
79