Jump to content

Using a function to connect to mysql.


tjmbc

Recommended Posts

Can I use this function:

 

function mysqldb(){

 

  $host = "host";

  $user = "user";

  $password = "password";

  $database = "database";

 

  mysql_connect($host,$user,$password) or die ("Unable to connect to the server.");

  mysql_select_db($database) or die ("Unable to connect to the database.");

}

 

to connect to my database by including it in each page and then calling it with:

 

mysqldb();

 

I know that this is something I should just try out and see what happens, but I can't at this time. Long story...

 

Link to comment
https://forums.phpfreaks.com/topic/103579-using-a-function-to-connect-to-mysql/
Share on other sites

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.