mysqli_error_unicode.phpt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. --TEST--
  2. mysqli_error()
  3. --SKIPIF--
  4. <?php
  5. require_once('skipif.inc');
  6. require_once('skipifemb.inc');
  7. require_once('skipifconnectfailure.inc');
  8. ?>
  9. --FILE--
  10. <?php
  11. require_once("connect.inc");
  12. $tmp = NULL;
  13. $link = NULL;
  14. if (!is_null($tmp = @mysqli_error()))
  15. printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  16. if (!is_null($tmp = @mysqli_error($link)))
  17. printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  18. if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
  19. printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
  20. $host, $user, $db, $port, $socket);
  21. }
  22. if (!(version_compare(PHP_VERSION, '5.9.9', '>') == 1)) {
  23. mysqli_query($link, "set names utf8");
  24. }
  25. $tmp = mysqli_error($link);
  26. if (!is_string($tmp) || ('' !== $tmp))
  27. printf("[004] Expecting string/empty, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link));
  28. mysqli_query($link, 'SELECT * FROM няма_такава_таблица');
  29. $tmp = mysqli_error($link);
  30. var_dump(str_replace($db.".", "", $tmp));
  31. mysqli_close($link);
  32. var_dump(mysqli_error($link));
  33. print "done!";
  34. ?>
  35. --EXPECTF--
  36. %unicode|string%(%d) "Table 'няма_такава_таблица' doesn't exist"
  37. Warning: mysqli_error(): Couldn't fetch mysqli in %s on line %d
  38. NULL
  39. done!