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