Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing Template on PHP
    text
    copied!<p>i create a template file for my site... it's like:</p> <pre><code>&lt;!-- template.php --&gt; &lt;?php function showheader() { ?&gt; &lt;head&gt;&lt;body&gt; &lt;!-- some of style files and menus --&gt; &lt;div class="content"&gt; &lt;?php } ?&gt; &lt;?php function showfooter() { ?&gt; &lt;/div&gt;&lt;/body&gt;&lt;/html&gt; &lt;?php } ?&gt; </code></pre> <p>i use this file as a template like this:</p> <pre><code>&lt;?php include_once("template.php"); showheader(); ?&gt; content text or photo or ... etc. &lt;?php showfooter(); ?&gt; </code></pre> <p>that's all... but if i try to use a connection on template file, it screw up! i used an external file like:</p> <pre><code>&lt;?php // // include_once connection file // query strings goes here // do { echo $row_table['id']; //example } while ($row_table = mysql_fetch_assoc($table)); ?&gt; </code></pre> <p>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...</p> <p>by the way, i use another external connection like:</p> <pre><code>&lt;?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'"); ?&gt; </code></pre> <p>i'm gonna cry! what's the problem... and do you know another way to use template... thanks much...</p> <p>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.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload