say i have a function link so
and in the same code i have a function like so
Is it really necessacary to put the $connect?
i was looking at a script that did this.... and i thought for sure i could use a
, and if i can just use global connect in
or do i just use connect.. can someone please try to clear this up?
PHP Code:
<?
include "config.php";
$connect = mysql_connect($db_host, $db_user, $db_pass) or die("Could not connect:" . mysql_error());
mysql_select_db('db_name', $connect) or die("Could not connect:" . mysql_error());
?>
PHP Code:
<?
$connect = mysql_connect($db_host, $db_user, $db_pass) or die("Could not connect:" . mysql_error());
mysql_select_db('db_name', $connect) or die("Could not connect:" . mysql_error());
function One($db_name, $db_host, $db_user, $db_pass) {
$connect = mysql_connect($db_host, $db_user, $db_pass) or die("Could not connect:" . mysql_error());
mysql_select_db('db_name', $connect) or die("Could not connect:" . mysql_error());
}
function Two($db_name, $db_host, $db_user, $db_pass) {
$connect = mysql_connect($db_host, $db_user, $db_pass) or die("Could not connect:" . mysql_error());
mysql_select_db('db_name', $connect) or die("Could not connect:" . mysql_error());
}
?>
i was looking at a script that did this.... and i thought for sure i could use a
PHP Code:
global $connect;
PHP Code:
mysql_select_db($db_name, $connect);
Comment