How does PHP know what the last database connection is when mysql_select_db() or mysql_query() is us

Posted by agscala on Stack Overflow See other posts from Stack Overflow or by agscala
Published on 2010-03-29T19:21:24Z Indexed on 2010/03/29 19:23 UTC
Read the original article Hit count: 123

Filed under:

Consider the following code:

<?php

$conn = mysql_connect('localhost', 'username', 'password');
mysql_select_db('database', $conn);

?>

This works as expected, but how does PHP know what database connection to use when calling mysql_select_db() in the following example?

<?php

mysql_connect('localhost', 'username', 'password');
mysql_select_db('database');

?>

© Stack Overflow or respective owner

Related posts about php