I am a PHP newbie. I am trying to pass a value retrieved from one query to another function where is will be used in another query. The showIndividual function appears to be working correctly based on the output produced. showIndividual then calls showParents. I think this is where my problem is.
----- Here is a copy of my php file.
<html>
<head>
<title>Family Tree</title>
</head>
<body>
<?php
include 'error.inc';
include 'db.inc';
function showIndividual($result)
{
$row = @ mysql_fetch_array($result);
//show first name, last name
echo $row["infname"] . " " . $row["inlname"] . "<br />";
//show family id just to test that we have right one
echo $row["infaid"] . "<br />";
//call showParents
showParents($connection, $row["infaid"]);
}
function showParents($connection, $id)
{
//query to select mother and father from family table based on family id from child
$query = "SELECT *
FROM family
WHERE family.faid = \"$id\"";
if (!($result = @ mysql_query ($query, $connection)))
showerror();
$row = @ mysql_fetch_array($result);
// show mother and father
echo "Father = " . $row["fafath"] . "<br />" .
"Mother = " . $row["famoth"] . "<br />";
}
// query to get id, first name, last name, family id equal to id passed in url
$query = "SELECT inid, infname, inlname, infaid
FROM individual
WHERE individual.inid = \"$id\"";
if (!($connection = @ mysql_connect($hostname, $username, $password)))
die("Can not connect");
if (!(mysql_select_db("travisbarden", $connection)))
showerror();
if (!($result = @ mysql_query ($query, $connection)))
showerror();
// call showIndividual function
showIndividual($result);
if (!(mysql_close($connection)))
showerror();
?>
</body>
</html>
------ Here is the output when running the file
FirstName LastName
F1
Error 0 :