1 (edited by Gary13579 2004-12-30 01:17)

Topic: PHP -- Including files in functions

Heres my problem. I have a file that handles many functions (functions.php). One of those functions echos a message, includes footer.php, and exits.
It displays the message fine, and exits, but just wont load the footer.php file.

Heres some code to help explain further

##functions.php
#
// This function will end the scirpt. and echo $message
function quiting($message) {
    echo $message;
    include("footer.php");
    exit;
}
#
##whatever.php
quiting("message");

#

and it doesnt work!
What it does is exucute the file perfectly up to the quiting("message");, then it will echo "message", and quit the script, without loading footer.php.

Anyone know what to do, or could it just be my server, and some setting I could fix in PHP.ini?

Indocron
$theQuestion = (2*b) || !(2*b);

Re: PHP -- Including files in functions

What does footer.php do then? What happens if you access just footer.php?

"Programming is like sex: one mistake and you have to support it for the rest of your life."

3 (edited by Gary13579 2004-12-30 01:39)

Re: PHP -- Including files in functions

footer.php will load fine on its own. header.php handles the login stuff (and other needed routines) as well as most of the style. footer.php has a little bit of style,  but it also has a mini chat type thing an a banner ad.

Wait a minute... To complicate things even further, the banner ad from footer.php is loading!
Heres footer.php

    </td>
            <td class="tblright"> </td>
        </tr>

        <tr>
            <td><img src="templates/<?php echo "$stat[style]"; ?>/tnav_bl.gif" width="14" height="26" alt="" /></td>
            <td class="tblbot"> </td>
            <td><img src="templates/<?php echo "$stat[style]"; ?>/tnav_br.gif" width="15" height="26" alt="" /></td>
        </tr>


<?php
if ($player[gold_member] || $player[babble_box]) {
?>
<!------begin babblebox--------->
        <tr>
            <td><img src="templates/<?php echo "$player[style]"; ?>/tnav_tl.gif" width="14" height="23" alt="" /></td>
            <td width="100%" class="tbltop"> </td>

            <td><img src="templates/<?php echo "$player[style]"; ?>/tnav_tr.gif" width="15" height="23" alt="" /></td>
        </tr>
        <tr>
            <td class="tblleft"> </td>
            <td background="templates/<?php echo "$player[style]"; ?>/cellbg.gif" id="charon_page_content">
<!--------------->
<iframe src="babblebox.php" name="sbox" width="100%" height="200" frameborder="0" id="bbox">Your browser does not support inline frames! The Babble Box will not be available until you upgrade to a newer <a href="http://www.mozilla.org" target="_new">browser</a>.</iframe>
<!--------------->
</td>
<td class="tblright"> </td>
</tr><tr>
<td><img src="templates/<?php echo "$player[style]"; ?>/tnav_bl.gif" width="14" height="26" alt="" /></td>
<td class="tblbot"> </td>
<td><img src="templates/<?php echo "$player[style]"; ?>/tnav_br.gif" width="15" height="26" alt="" /></td></tr>
<!--------------->
<?php
}

?>
    </table>

<center><br><!-- Clicksor.com Advertising Code Begin -->
<script type='text/javascript'>
<!--
clicksor_banner_border = '#000000';
clicksor_banner_ad_bg = '#333333';
clicksor_banner_link_color = '#FFFF00';
clicksor_banner_text_color = '#ffffff';
clicksor_banner_image_banner = false;
//-->
</script>
<script type='text/javascript' src='http://www.clicksor.com/showAd.php?pid=5062&sid=6680&adtype=2'></script>
<!-- Clicksor.com Advertising Code End --></center>
    </TD>
        </TR>
    </TABLE>
</CENTER>

</BODY>
</HTML>

The style and chat wont load, but the banner ad loads fine.

edit: I love the way that 1.2 handles the code tags smile

Indocron
$theQuestion = (2*b) || !(2*b);

Re: PHP -- Including files in functions

won't you need to global all the variables in footer.php in function quiting($message) {?

Re: PHP -- Including files in functions

global what? Ive never used global, so I dont know what Id have to do.

Indocron
$theQuestion = (2*b) || !(2*b);

Re: PHP -- Including files in functions

all variables in functions are separate to functions elsewhere in the script, if you want to share variables you need to say

global $var1, $var2, $var3;

etc at the beginning of the function, for arrays you just name the array e.g. for $player[style] just say $player

Re: PHP -- Including files in functions

works big_smile
I really need to tidy up my PHP. I always relie and stuff like register_globals in php.ini..

Thanks smile

Indocron
$theQuestion = (2*b) || !(2*b);