#30055 [NEW]: incorrect example

From: Date: Fri, 10 Sep 2004 16:48:18 +0000
Subject: #30055 [NEW]: incorrect example
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-26164@lists.php.net to get a copy of this message
From: slick dot user at gmail dot com Operating system: PHP version: Irrelevant PHP Bug Type: Website problem Bug description: incorrect example Description: ------------ in the manual under mysql_field_name(), http://us2.php.net/manual/en/function.mysql-field-name.php. Example 1 is incorrect, the if statement after mysql_connect will always run true and the die statement will always run. Nick Reproduce code: --------------- <?php /* The users table consists of three fields: * user_id * username * password. */ $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); if (!$db_selected) { die('Could not set $dbname: ' . mysql_error()); } $dbname = 'mydb'; $db_selected = mysql_select_db($dbname, $link); if (!$db_selected) { die('Could not set $dbname: ' . mysql_error()); } $res = mysql_query('select * from users', $link); echo mysql_field_name($res, 0) . "\n"; echo mysql_field_name($res, 2); ?> Expected result: ---------------- The above code would produce: Could not set : The if was probably suppose to check $link, not $db_selected -- Edit bug report at http://bugs.php.net/?id=30055&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30055&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30055&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30055&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=30055&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=30055&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=30055&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=30055&r=needscript Try newer version: http://bugs.php.net/fix.php?id=30055&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=30055&r=support Expected behavior: http://bugs.php.net/fix.php?id=30055&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=30055&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=30055&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=30055&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30055&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=30055&r=dst IIS Stability: http://bugs.php.net/fix.php?id=30055&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=30055&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=30055&r=float MySQL Configuration Error: http://bugs.php.net/fix.php?id=30055&r=mysqlcfg

« previous php.mirrors (#26164) next »