PHP is unusual in that global variables have to be declared global in the given scope. As such, you would write:
<?php
$global_handle = mysql_connect("host", "user", "pass");
mysql_select_db("test", $global_handle);
first_func(); // You need to actually call a function.
function first_func() {
global $global_handle;
$qryStr = "SELECT * FROM table";
$result_id = mysql_query($qryStr, $global_handle);
call_second_func();
}
function call_second_func() {
global $global_handle;
$qryStr = "SELECT * FROM table";
$result_id = mysql_query($qryStr, $global_handle);
}
?>
I would suggest passing handles by reference as opposed to using a global handle. After all, the whole point of specifying the handle is so that you can use different handles.
<?php
$db_handle = mysql_connect("host", "user", "pass");
mysql_select_db("test", $db_handle);
first_func($db_handle);
function first_func(&$db_handle) {
$qryStr = "SELECT * FROM table";
$result_id = mysql_query($qryStr, $db_handle);
call_second_func($db_handle);
}
function call_second_func(&$db_handle) {
$qryStr = "SELECT * FROM table";
$result_id = mysql_query($qryStr, $db_handle);
}
?>