Annotation of embedaddon/php/ext/mysql/tests/mysql_errno.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: mysql_errno()
! 3: --SKIPIF--
! 4: <?php
! 5: require_once('skipif.inc');
! 6: require_once('skipifconnectfailure.inc');
! 7: ?>
! 8: --FILE--
! 9: <?php
! 10: include "connect.inc";
! 11:
! 12: $tmp = NULL;
! 13: $link = NULL;
! 14:
! 15: if (false !== ($tmp = @mysql_errno()))
! 16: printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
! 17:
! 18: if (null !== ($tmp = @mysql_errno($link)))
! 19: printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
! 20:
! 21: if (!is_null($tmp = @mysql_errno($link, 'too many args')))
! 22: printf("[002b] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
! 23:
! 24: if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) {
! 25: printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
! 26: $host, $user, $db, $port, $socket);
! 27: }
! 28: var_dump(mysql_errno($link));
! 29:
! 30: if (!mysql_query('DROP TABLE IF EXISTS test', $link)) {
! 31: printf("[004] Failed to drop old test table: [%d] %s\n", mysql_errno($link), mysql_errno($link));
! 32: }
! 33:
! 34: mysql_query('SELECT * FROM test', $link);
! 35: var_dump(mysql_errno($link));
! 36:
! 37: mysql_close($link);
! 38:
! 39: var_dump(mysql_errno($link));
! 40:
! 41: if ($link = @mysql_connect($host . '_unknown', $user . '_unknown', $passwd, true)) {
! 42: printf("[005] Can connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
! 43: $host . '_unknown', $user . '_unknown', $db, $port, $socket);
! 44: } else {
! 45: $errno = mysql_errno();
! 46: if (!is_int($errno))
! 47: printf("[006] Expecting int/any (e.g 1046, 2005) got %s/%s\n", gettype($errno), $errno);
! 48:
! 49: }
! 50:
! 51: print "done!";
! 52: ?>
! 53: --CLEAN--
! 54: <?php
! 55: require_once("clean_table.inc");
! 56: ?>
! 57: --EXPECTF--
! 58: int(0)
! 59: int(%d)
! 60:
! 61: Warning: mysql_errno(): %d is not a valid MySQL-Link resource in %s on line %d
! 62: bool(false)
! 63: done!
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>