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