1--TEST--
2mysql_set_charset() - STUB, function usage not recommended
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7
8if (version_compare(PHP_VERSION, '5.9.9', '>') == 1) {
9	die('skip set character set not functional with PHP 6 (fomerly PHP 6 && unicode.semantics=On)');
10}
11
12if (!function_exists('mysql_set_charset'))
13	die("skip Function not available");
14?>
15--FILE--
16<?php
17include_once "connect.inc";
18
19$tmp    = NULL;
20$link   = NULL;
21
22if (!is_null($tmp = @mysql_set_charset()))
23	printf("[001] Expecting NULL got %s/%s\n", $tmp, gettype($tmp));
24
25if (false !== ($tmp = @mysql_set_charset($link)))
26	printf("[002] Expecting boolean/false got %s/%s\n", $tmp, gettype($tmp));
27
28if (false !== ($tmp = @mysql_set_charset(-1)))
29	printf("[003] Expecting boolean/false got %s/%s\n", $tmp, gettype($tmp));
30
31if (!is_null($tmp = @mysql_set_charset('somecharset', $link)))
32	printf("[004] Expecting NULL got %s/%s\n", $tmp, gettype($tmp));
33
34if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket))
35	printf("[005] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
36		$host, $user, $db, $port, $socket);
37
38/* unicode mode should throw a warning */
39$tmp = mysql_set_charset('uFt8', $link);
40
41if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1))
42	$expect = false;
43else
44	$expect = true;
45
46$charsets = array('latin1', 'latin2');
47foreach ($charsets as $k => $charset) {
48	if (!($res = mysql_query(sprintf('SHOW CHARACTER SET LIKE "%s"', $charset), $link)))
49		continue;
50	mysql_free_result($res);
51	if ($expect !== ($tmp = @mysql_set_charset($charset, $link)))
52		printf("[006] Expecting %s/%s got %s/%s\n",
53			gettype($expect), $expect,
54			gettype($tmp), $tmp);
55}
56
57mysql_close($link);
58print "done!";
59?>
60--EXPECTF--
61Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
62done!
63