Jump to content

Mysql In Functions?


Cod-nes
 Share

Recommended Posts

Do we have to recall the mysql when making a function?Example:

<?phpmysql_connect("server","user","password") or die();mysql_select_db("database") or die();function countrows() {// Do we need to reconnect so that this function can work? //mysql_connect("server","user","password") or die();//mysql_select_db("database") or die();$sql = mysql_query("SELECT *");$sql = mysql_count_rows($sql);//mysql_close();return $sql;}mysql_close();?>

Edited by Cod-nes
Link to comment
Share on other sites

All php_mysql versions look for the connection handler in the global namespace. So you don't need to re-connect.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...