solematejass Posted January 10, 2011 Share Posted January 10, 2011 Hi all i am new to this stuff, got one query if possible please explain. mysql_connect("localhost","mysql_username","mysql_password"); mysql_select_db("testdb"); $result = mysql_query("SELECT id, name FROM users"); while ($row = mysql_fetch_array($result, MYSQL_NUM)) { echo $row['id'],$row[1]; } mysql_free_result($result); Quote Link to comment https://forums.phpfreaks.com/topic/223962-what-is-the-output-of-the-following-code-assume-users-table-contain-data/ Share on other sites More sharing options...
Pikachu2000 Posted January 10, 2011 Share Posted January 10, 2011 What do you mean 'what is the output'? It should output the id field and name field. Why, what output do you get when you run it? Quote Link to comment https://forums.phpfreaks.com/topic/223962-what-is-the-output-of-the-following-code-assume-users-table-contain-data/#findComment-1157392 Share on other sites More sharing options...
PFMaBiSmAd Posted January 10, 2011 Share Posted January 10, 2011 Sounds like a job interview quiz. Depending on your error_reporting and display_errors settings, you will either get a bunch of undefined index messages (for $row['id']) followed by the name values or you will get only the name values. Quote Link to comment https://forums.phpfreaks.com/topic/223962-what-is-the-output-of-the-following-code-assume-users-table-contain-data/#findComment-1157401 Share on other sites More sharing options...
Pikachu2000 Posted January 10, 2011 Share Posted January 10, 2011 Oops. Overlooked the MYSQL_NUM parameter there. Pity if it cost someone a job they obviously aren't qualified for. Quote Link to comment https://forums.phpfreaks.com/topic/223962-what-is-the-output-of-the-following-code-assume-users-table-contain-data/#findComment-1157407 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.