Jump to content

What is the output of the following code? (Assume users table contain data)


solematejass

Recommended Posts

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);

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.