Jump to content

Mysql In Functions?


Cod-nes

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

Link to comment
Share on other sites

Guest FirefoxRocks

I'm not sure, my guess is that it applies to all versions of PHP that supported mysql_connect or mysqli_connect.

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

Archived

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

×
×
  • Create New...