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