1--TEST--
2mysqli_real_escape_string() - eucjpms
3--SKIPIF--
4<?php
5
6require_once('skipif.inc');
7require_once('skipifconnectfailure.inc');
8require_once('connect.inc');
9
10if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
11    die(sprintf("skip Cannot connect to MySQL, [%d] %s\n",
12        mysqli_connect_errno(), mysqli_connect_error()));
13}
14if (!mysqli_set_charset($link, 'eucjpms'))
15    die(sprintf("skip Cannot set charset 'eucjpms'"));
16mysqli_close($link);
17?>
18--FILE--
19<?php
20require_once("connect.inc");
21
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=eucjpms")) {
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, "eucjpms"));
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