Code:
db_connect.php
<?php
function connect_db()
{
global $link;
$link = mysql_connect("localhost", "root","protocol");
mysql_select_db("claims",$link);
return $link;
}
?>
claim_no.php
<?php
function claimno()
{
global $claim_no;
$link = mysql_connect("localhost", "root","protocol");
mysql_select_db("claims",$link);
$sql = "SELECT max(claim_no) as claim_no FROM claim_details;";
$result = @mysql_query($sql, $link) ;
while ($row = mysql_fetch_array($result))
{
$f1=$row['claim_no'];
}
if($f1==0)
{
$claim_no=1;
}
else
{
//print "Max claim_no : ".$f1->value."<br>";
$claim_no=$f1;
$claim_no=$claim_no+1;
//echo "New shgid =".$shgid;
}
}
?>
I would like to replace
Code:
$link = mysql_connect("localhost", "root","protocol");
mysql_select_db("claims",$link);
in claim_no.php with this code
Code:
include 'db_connect.php';
connect_db();
But it seems to be not working as the value of link from db_connect.php is not passed onto claim_no.php
In short how do i call a php function from within another function