bug47438.phpt 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. --TEST--
  2. Bug #47438 (mysql_fetch_field ignores zero offset)
  3. --SKIPIF--
  4. <?php
  5. require_once('skipif.inc');
  6. require_once('skipifconnectfailure.inc');
  7. ?>
  8. --FILE--
  9. <?php
  10. require_once('connect.inc');
  11. if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket))
  12. printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
  13. $host, $user, $db, $port, $socket);
  14. mysql_select_db($db, $link);
  15. mysql_query("DROP TABLE IF EXISTS test_47438", $link);
  16. mysql_query("CREATE TABLE test_47438 (a INT, b INT, c INT)", $link);
  17. mysql_query("INSERT INTO test_47438 VALUES (10, 11, 12), (20, 21, 22)", $link);
  18. $result = mysql_query("SELECT * FROM test_47438", $link);
  19. mysql_field_seek($result, 1);
  20. $i = 0;
  21. while($i<mysql_num_fields($result))
  22. {
  23. $meta=mysql_fetch_field($result,$i);
  24. echo $i . "." . $meta->name . "\n";
  25. $i++;
  26. }
  27. mysql_query("DROP TABLE IF EXISTS test_47438", $link);
  28. ?>
  29. --CLEAN--
  30. <?php
  31. require_once('connect.inc');
  32. if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket))
  33. printf("[c001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
  34. $host, $user, $db, $port, $socket);
  35. if (!mysql_select_db($db, $link) ||
  36. !mysql_query("DROP TABLE IF EXISTS test_47438", $link))
  37. printf("[c002] [%d] %s\n", mysql_errno($link), mysql_error($link));
  38. mysql_close($link);
  39. ?>
  40. --EXPECTF--
  41. 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
  42. 0.a
  43. 1.b
  44. 2.c