1--TEST--
2mysql_free_result()
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7?>
8--FILE--
9<?php
10include "connect.inc";
11
12$tmp    = NULL;
13$link   = NULL;
14
15if (!is_null($tmp = @mysql_free_result()))
16	printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
17
18if (null !== ($tmp = @mysql_free_result($link)))
19	printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
20
21require('table.inc');
22if (!$res = mysql_query("SELECT id FROM test ORDER BY id LIMIT 1", $link)) {
23	printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link));
24}
25
26var_dump(mysql_free_result($res));
27var_dump(mysql_free_result($res));
28
29if ($tmp = sys_get_temp_dir()) {
30	$tmpname = tempnam($tmp, 'free_result');
31	if ($fp = fopen($tmpname, 'w')) {
32		if (false !== ($tmp = @mysql_free_result($fp)))
33			printf("[004] Expecting boolean/false got %s/%s\n", gettype($tmp), $tmp);
34		fclose($fp);
35		@unlink($tmpname);
36	}
37}
38
39mysql_close($link);
40print "done!";
41?>
42--CLEAN--
43<?php
44require_once("clean_table.inc");
45?>
46--EXPECTF--
47bool(true)
48
49Warning: mysql_free_result(): %d is not a valid MySQL result resource in %s on line %d
50bool(false)
51done!
52