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