PHP  
 PHP_5_6
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

Test Failure Report for ext/mysql/tests/mysql_num_rows.phpt ('mysql_num_rows()')

Script

1: <?php
2:
include "connect.inc";
3:
4:
$tmp    NULL;
5:
$link   NULL;
6:
7: if (!
is_null($tmp = @mysql_num_rows()))
8:
printf("[001] Expecting NULL, got %s/%s\n"gettype($tmp), $tmp);
9:
10: if (
NULL !== ($tmp = @mysql_num_rows($link)))
11:
printf("[002] Expecting NULL, got %s/%s\n"gettype($tmp), $tmp);
12:
13: require(
'table.inc');
14:
15: function 
func_test_mysql_num_rows($link$query$expected$offset$test_free false) {
16:
17:     if (!
$res mysql_query($query$link)) {
18:         
printf("[%03d] [%d] %s\n"$offsetmysql_errno($link), mysql_error($link));
19:         return;
20:     }
21:
22:     if (
$expected !== ($tmp mysql_num_rows($res)))
23:         
printf("[%03d] Expecting %s/%d, got %s/%d\n"$offset 1,
24:             
gettype($expected), $expected,
25:             
gettype($tmp), $tmp);
26:
27:     
mysql_free_result($res);
28:
29:     if (
$test_free && (false !== ($tmp mysql_num_rows($res))))
30:         
printf("[%03d] Expecting boolean/false, got %s/%s\n"$offset 2gettype($tmp), $tmp);
31: }
32:
33:
func_test_mysql_num_rows($link"SELECT 1 AS a"15);
34:
func_test_mysql_num_rows($link"SHOW VARIABLES LIKE '%nixnutz%'"010);
35:
func_test_mysql_num_rows($link"INSERT INTO test(id, label) VALUES (100, 'z')"NULL15);
36:
func_test_mysql_num_rows($link"SELECT id FROM test LIMIT 2"220true);
37:
38: if (
$res mysql_query('SELECT COUNT(id) AS num FROM test'$link)) {
39:
40:     
$row mysql_fetch_assoc($res);
41:     
mysql_free_result($res);
42:
43:     
func_test_mysql_num_rows($link"SELECT id, label FROM test", (int)$row['num'], 25);
44:
45: } else {
46:     
printf("[030] [%d] %s\n"mysql_errno($link), mysql_error($link));
47: }
48:
49: if (
$res mysql_unbuffered_query('SELECT id, label FROM test')) {
50:
51:     if (
!= mysql_num_rows($res))
52:         
printf("[032] Expecting 0 rows got %d\n"mysql_num_rows($res));
53:     
54:     
$rows 0;
55:     while (
$row mysql_fetch_assoc($res))
56:         
$rows++;
57:
58:     if (
$rows != mysql_num_rows($res))
59:         
printf("[033] Expecting %d rows got %d\n"$rowsmysql_num_rows($res));
60:
61:     
mysql_free_result($res);
62: } else {
63:     
printf("[034] [%d] %s\n"mysql_errno($link), mysql_error($link));
64: }
65:
66:
mysql_close($link);
67: print 
"done!";
68:
?>
69:

Expected

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in %s on line %d

Warning: mysql_free_result() expects parameter 1 to be resource, boolean given in %s on line %d

Warning: mysql_num_rows(): %d is not a valid MySQL result resource in %s on line %d
done!

Output

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /var/php_gcov/PHP_5_6/ext/mysql/tests/connect.inc on line 37
Out of memory

Diff

002+ Out of memory
002- 
003- Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in %s on line %d
004- 
005- Warning: mysql_free_result() expects parameter 1 to be resource, boolean given in %s on line %d
006- 
007- Warning: mysql_num_rows(): %d is not a valid MySQL result resource in %s on line %d
008- done!

 

Generated at Mon, 27 Nov 2017 05:04:32 +0000 (18 days ago)

Copyright © 2005-2017 The PHP Group
All rights reserved.