mysqli_connect_errno.phpt 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. --TEST--
  2. mysqli_connect_errno()
  3. --EXTENSIONS--
  4. mysqli
  5. --SKIPIF--
  6. <?php
  7. require_once('skipifconnectfailure.inc');
  8. ?>
  9. --FILE--
  10. <?php
  11. require_once("connect.inc");
  12. $tmp = NULL;
  13. $link = NULL;
  14. // too many parameter
  15. try {
  16. mysqli_connect_errno($link);
  17. } catch (ArgumentCountError $exception) {
  18. print($exception->getMessage() . "\n");
  19. }
  20. if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
  21. printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
  22. $host, $user, $db, $port, $socket);
  23. if (0 !== ($tmp = mysqli_connect_errno()))
  24. printf("[003] Expecting integer/0, got %s/%s\n", gettype($tmp), $tmp);
  25. mysqli_close($link);
  26. $link = @my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket);
  27. if (false !== $link)
  28. printf("[004] Connect to the server should fail using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s, expecting boolean/false, got %s/%s\n",
  29. $host, $user . 'unknown_really', $db, $port, $socket, gettype($link), var_export($link, true));
  30. if (0 === ($tmp = mysqli_connect_errno()))
  31. printf("[005] Expecting integer/any non-zero, got %s/%s\n", gettype($tmp), $tmp);
  32. print "done!";
  33. ?>
  34. --EXPECT--
  35. mysqli_connect_errno() expects exactly 0 arguments, 1 given
  36. done!