i create a template file for my site... it's like:
<!-- template.php -->
<?php function showheader() { ?>
<head><body>
<!-- some of style files and menus -->
<div class="content">
<?php } ?>
<?php function showfooter() { ?>
</div></body></html>
<?php } ?>
i use this file as a template like this:
<?php include_once("template.php"); showheader(); ?>
content text or photo or ... etc.
<?php showfooter(); ?>
that's all... but if i try to use a connection on template file, it screw up! i used an external file like:
<?php
//
// include_once connection file
// query strings goes here
//
do {
echo $row_table['id']; //example
} while ($row_table = mysql_fetch_assoc($table));
?>
and i use this file as include_once("filename.php"); on template file... at this point it gives errors... like what is this connection variable, what is this connection string... etc. it cannot reach connection strings...
by the way, i use another external connection like:
<?php
global $hostname_conn,$database_conn,$username_conn,$password_conn,$conn;
$hostname_conn = "localhost";
$database_conn = "test";
$username_conn = "****";
$password_conn = "****";
$conn = mysql_pconnect($hostname_conn, $username_conn, $password_conn) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_query("SET NAMES 'utf8'");
?>
i'm gonna cry! what's the problem... and do you know another way to use template... thanks much...
PS: i change variables on conn.php as global (and it didnt work) and i change include, include_once, require, require_once where i include files but it didnt give anything.