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