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