1--TEST--
2mysqli_real_escape_string() - sjis
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7require_once('connect.inc');
8
9if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
10    die(sprintf("skip Cannot connect to MySQL, [%d] %s\n",
11        mysqli_connect_errno(), mysqli_connect_error()));
12}
13if (!mysqli_set_charset($link, 'sjis'))
14    die(sprintf("skip Cannot set charset 'sjis'"));
15mysqli_close($link);
16?>
17--FILE--
18<?php
19
20    require_once("connect.inc");
21    require_once('table.inc');
22
23    var_dump(mysqli_set_charset($link, "sjis"));
24
25    if ('?p??\\\\?p??' !== ($tmp = mysqli_real_escape_string($link, '?p??\\?p??')))
26        printf("[004] Expecting \\\\, got %s\n", $tmp);
27
28    if ('?p??\"?p??' !== ($tmp = mysqli_real_escape_string($link, '?p??"?p??')))
29        printf("[005] Expecting \", got %s\n", $tmp);
30
31    if ("?p??\'?p??" !== ($tmp = mysqli_real_escape_string($link, "?p??'?p??")))
32        printf("[006] Expecting ', got %s\n", $tmp);
33
34    if ("?p??\\n?p??" !== ($tmp = mysqli_real_escape_string($link, "?p??\n?p??")))
35        printf("[007] Expecting \\n, got %s\n", $tmp);
36
37    if ("?p??\\r?p??" !== ($tmp = mysqli_real_escape_string($link, "?p??\r?p??")))
38        printf("[008] Expecting \\r, got %s\n", $tmp);
39
40    if ("?p??\\0?p??" !== ($tmp = mysqli_real_escape_string($link, "?p??" . chr(0) . "?p??")))
41        printf("[009] Expecting %s, got %s\n", "?p??\\0?p??", $tmp);
42
43    var_dump(mysqli_query($link, "INSERT INTO test(id, label) VALUES (100, '?p')"));
44
45    mysqli_close($link);
46    print "done!";
47?>
48--EXPECT--
49bool(true)
50bool(true)
51done!
52