bnjmn.myers bnjmn.myers - 5 months ago 10
PHP Question

PHP Calling more than one function

I have a page where I'm housing all of my functions that make calls to the database. In my display page I'm trying to make calls to 2 separate functions. Is this not possible to do? Below is my code.

<?php
include 'includes/getData.php';
$memberBios = getActiveMemberBios();
$internBios = getActiveInternBios();
?>

<h3>Members</h3>
<?php
while($member = mysql_fetch_array($memberBios))
{
$bioPic = $member['bioPic'];
$bioText = $member['bioText'];
$firstname = $member['firstname'];
$maidenname = $member['maidenname'];
$memberRole = $member['memberRole'];
$lastname = $member['lastname'];

echo
"<div class='row row__off-1 col-lg-12 wow fadeInUp' data-wow-delay='0.2s'>
<div class='col-lg-3 col-md-3 col-sm-12'>
<div class='text-center'>
<img src='".$bioPic."' alt='Biography Picture of Zion Dance Company Member '".$firstname.' '.$lastname." title='Biography Picture of Zion Dance Company Member '".$firstname.' '.$lastname. "height='305' width='270'/>
</div>
</div>
<div class='col-lg-9 col-md-9 col-sm-12 text-center-xs'>
<h5 class='font-secondary-3'>
<a href='#'>".$firstname.' '.$maidenname.' '.$lastname."</a>
</h5>
<p class='color-primary off'>".$memberRole."</p>

<p>".$bioText."</p>
</div>
</div>";
}
?>
<h3>Interns</h3>
<?php
while($intern = mysql_fetch_array($internBios))
{
$bioPic = $intern['bioPic'];
$bioText = $intern['bioText'];
$firstname = $intern['firstname'];
$maidenname = $intern['maidenname'];
$memberRole = $intern['memberRole'];
$lastname = $intern['lastname'];

echo
"<div class='row row__off-1 col-lg-12 wow fadeInUp' data-wow-delay='0.2s'>
<div class='col-lg-3 col-md-3 col-sm-12'>
<div class='text-center'>
<img src='".$bioPic."' alt='Biography Picture of Zion Dance Company Member '".$firstname.' '.$lastname." title='Biography Picture of Zion Dance Company Member '".$firstname.' '.$lastname. "height='305' width='270'/>
</div>
</div>
<div class='col-lg-9 col-md-9 col-sm-12 text-center-xs'>
<h5 class='font-secondary-3'>
<a href='#'>".$firstname.' '.$maidenname.' '.$lastname."</a>
</h5>
<p class='color-primary off'>".$memberRole."</p>

<p>".$bioText."</p>
</div>
</div>";
}
?>


Each method is calling a different stored procedure.

Each methods returns the data properly until they are called one right after the other.

function getActiveMemberBios()
{
mysql_connect(ZDANCE_CONNECTION, ZDANCE_USER, ZDANCE_PASS);
if(mysql_ping())
{
mysql_select_db(ZDANCE_HOST);
$result = mysql_query("CALL usp_GetMemberBios(1)") or die("Query fail: " . mysql_error());

return $result;

mysql_close();
}
}

function getActiveInternBios()
{
mysql_connect(ZDANCE_CONNECTION, ZDANCE_USER, ZDANCE_PASS);
if(mysql_ping())
{
mysql_select_db(ZDANCE_HOST);
$result = mysql_query("CALL usp_GetInternBios(1)") or die("Query fail: " . mysql_error());

return $result;

mysql_close();
}
}


Any help is greatly appreciated.

Thanks,
bnjmnmyers

Answer

Try to replace this part of your functions code

return $result;

mysql_close();

with this

mysql_close();

return $result;