1--TEST--
2mysqli_real_escape_string() - euckr
3--SKIPIF--
4<?php
5if (ini_get('unicode.semantics'))
6	die("skip Test cannot be run in unicode mode");
7
8require_once('skipif.inc');
9require_once('skipifemb.inc');
10require_once('skipifconnectfailure.inc');
11require_once('connect.inc');
12
13if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
14	die(sprintf("skip Cannot connect to MySQL, [%d] %s\n",
15		mysqli_connect_errno(), mysqli_connect_error()));
16}
17if (!mysqli_set_charset($link, 'euckr'))
18	die(sprintf("skip Cannot set charset 'euckr'"));
19mysqli_close($link);
20?>
21--FILE--
22<?php
23	require_once("connect.inc");
24	if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
25{
26		printf("[001] Cannot connect to the server using host=%s, user=%s,
27passwd=***, dbname=%s, port=%s, socket=%s - [%d] %s\n", $host, $user, $db,
28$port, $socket, mysqli_connect_errno(), mysqli_connect_error());
29	}
30
31	if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) {
32		printf("Failed to drop old test table: [%d] %s\n", mysqli_errno($link),
33mysqli_error($link));
34	}
35
36	if (!mysqli_query($link, 'CREATE TABLE test(id INT, label CHAR(1), PRIMARY
37KEY(id)) ENGINE=' . $engine . " DEFAULT CHARSET=euckr")) {
38		printf("Failed to create test table: [%d] %s\n", mysqli_errno($link),
39mysqli_error($link));
40	}
41
42	var_dump(mysqli_set_charset($link, "euckr"));
43
44	if ('�Ǵ뼺\\\\�Ǵ뼺' !== ($tmp = mysqli_real_escape_string($link, '�Ǵ뼺\\�Ǵ뼺')))
45		printf("[004] Expecting \\\\, got %s\n", $tmp);
46
47	if ('�Ǵ뼺\"�Ǵ뼺' !== ($tmp = mysqli_real_escape_string($link, '�Ǵ뼺"�Ǵ뼺')))
48		printf("[005] Expecting \", got %s\n", $tmp);
49
50	if ("�Ǵ뼺\'�Ǵ뼺" !== ($tmp = mysqli_real_escape_string($link, "�Ǵ뼺'�Ǵ뼺")))
51		printf("[006] Expecting ', got %s\n", $tmp);
52
53	if ("�Ǵ뼺\\n�Ǵ뼺" !== ($tmp = mysqli_real_escape_string($link, "�Ǵ뼺\n�Ǵ뼺")))
54		printf("[007] Expecting \\n, got %s\n", $tmp);
55
56	if ("�Ǵ뼺\\r�Ǵ뼺" !== ($tmp = mysqli_real_escape_string($link, "�Ǵ뼺\r�Ǵ뼺")))
57		printf("[008] Expecting \\r, got %s\n", $tmp);
58
59	if ("�Ǵ뼺\\0�Ǵ뼺" !== ($tmp = mysqli_real_escape_string($link, "�Ǵ뼺" . chr(0) . "�Ǵ뼺")))
60		printf("[009] Expecting %s, got %s\n", "�Ǵ뼺\\0�Ǵ뼺", $tmp);
61
62	var_dump(mysqli_query($link, "INSERT INTO test(id, label) VALUES (100, '��')"));
63
64	mysqli_close($link);
65	print "done!";
66?>
67--CLEAN--
68<?php
69	require_once("clean_table.inc");
70?>
71--EXPECTF--
72bool(true)
73bool(true)
74done!
75