1--TEST-- 2mysql_pconnect() 3--SKIPIF-- 4<?php 5require_once('skipif.inc'); 6require_once('skipifconnectfailure.inc'); 7?> 8--INI-- 9mysql.max_persistent=10 10mysql.allow_persistent=1 11--FILE-- 12<?php 13 include "connect.inc"; 14 15 $tmp = NULL; 16 $link = NULL; 17 18 // mysql_pconnect ( [string server [, string username [, string password [, bool new_link [, int client_flags]]]]] ) 19 if (NULL !== ($tmp = @mysql_pconnect($link, $link, $link, $link, $link, $link))) 20 printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); 21 22 $myhost = (is_null($socket)) ? ((is_null($port)) ? $host : $host . ':' . $port) : $host . ':' . $socket; 23 if (!$link = mysql_pconnect($myhost, $user, $passwd, true)) 24 printf("[002] Cannot connect to the server using host=%s/%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", 25 $host, $myhost, $user, $db, $port, $socket); 26 27 mysql_close($link); 28 29 if ($link = mysql_pconnect($myhost, $user . 'unknown_really', $passwd . 'non_empty', true)) 30 printf("[003] Can connect to the server using host=%s/%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", 31 $host, $myhost, $user . 'unknown_really', $db, $port, $socket); 32 33 if (false !== $link) 34 printf("[004] Expecting boolean/false, got %s/%s\n", gettype($link), $link); 35 36 // Run the following tests without an anoynmous MySQL user and use a password for the test user! 37 38 39 if (!ini_get('sql.safe_mode')) { 40 41 if ($socket) { 42 ini_set('mysql.default_socket', $socket); 43 if (!is_resource($link = mysql_pconnect($host, $user, $passwd, true))) { 44 printf("[005] Usage of mysql.default_socket failed\n") ; 45 } else { 46 mysql_close($link); 47 } 48 } else { 49 ini_set('mysql.default_socket', null); 50 } 51 52 ini_set('mysql.default_port', $port); 53 if (!is_resource($link = mysql_pconnect($host, $user, $passwd, true))) { 54 printf("[006] Usage of mysql.default_port failed\n") ; 55 } else { 56 mysql_close($link); 57 } 58 59 ini_set('mysql.default_password', $passwd); 60 if (!is_resource($link = mysql_pconnect($myhost, $user))) { 61 printf("[007] Usage of mysql.default_password failed\n") ; 62 } else { 63 mysql_close($link); 64 } 65 66 ini_set('mysql.default_user', $user); 67 if (!is_resource($link = mysql_pconnect($myhost))) { 68 printf("[008] Usage of mysql.default_user failed\n"); 69 } else { 70 mysql_close($link); 71 } 72 73 ini_set('mysql.default_host', $myhost); 74 if (!is_resource($link = mysql_pconnect())) { 75 printf("[009] Usage of mysql.default_host failed\n") ; 76 } else { 77 mysql_close($link); 78 } 79 } 80 81 print "done!"; 82?> 83--EXPECTF-- 84Warning: mysql_pconnect(): Access denied for user '%s'@'%s' (using password: YES) in %s on line %d 85done! 86