Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5928943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:21:20+00:00 2026-05-22T14:21:20+00:00

I have a blog written in PHP which uses MySQL as its’ back-end. There

  • 0

I have a blog written in PHP which uses MySQL as its’ back-end. There is a template for blog posts stored in the database and the script pulls this content when it is needed. How can I make it so I do not need to store the template in my database and in my PHP file instead?

My PHP code is:

<?php

$dbhost="localhost";
$dbname="database";
$dbuser="username";
$dbpass="password";
$mysql=@mysql_select_db($dbname, @mysql_connect($dbhost, $dbuser, $dbpass)) or die (mysql_error());

if (($_GET['act'] == "blog") && (is_numeric($_GET['id']))) {
$temp = mysql_fetch_row(mysql_query("SELECT template FROM templates WHERE name = 'blog'"));
$sql = mysql_query("SELECT * FROM posts WHERE id = '".$_GET['id']."'");
while($r = mysql_fetch_array($sql)) {
$pab[0] = "/{subject}/";
$pab[1] = "/{date}/";
$pab[2] = "/{blog}/";
$rab[0] = "<a href='blog-".$r[id].".html'>".stripslashes($r[subject])."</a>";
$rab[1] = $r[date];
$rab[2] = stripslashes($r[blog])."<br /><br />";
eval (" ?>" . preg_replace($pab, $rab, stripslashes($temp[0])) . " <?php ");
}
}
?>

Here is the code stored in the database:

<table cellpadding='0' cellspacing='0' border='0' align='center' width='394'>
<tr>
<td><font face='Tahoma' size='4' color='#3A3A3A'><b>{subject}</b></font></td>
</tr>
<tr>
<td>{blog}</td>
</tr>
</table>

My question is; How can I make it so I do not need to store the template in my database and in my PHP file instead?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T14:21:20+00:00Added an answer on May 22, 2026 at 2:21 pm

    You mean like this?

    <?php
    
    $dbhost="localhost";
    $dbname="database";
    $dbuser="username";
    $dbpass="password";
    $mysql=@mysql_select_db($dbname, @mysql_connect($dbhost, $dbuser, $dbpass)) or die (mysql_error());
    
    if (($_GET['act'] == "blog") && (is_numeric($_GET['id']))) {
        $temp = "<table cellpadding='0' cellspacing='0' border='0' align='center' width='394'>
            <tr>
                <td><font face='Tahoma' size='4' color='#3A3A3A'><b>{subject}</b></font></td>
            </tr>
            <tr>
                <td>{blog}</td>
            </tr>
        </table>";
        $sql = mysql_query("SELECT * FROM posts WHERE id = '".$_GET['id']."'");
        while($r = mysql_fetch_array($sql)) {
           $pab[0] = "/{subject}/";
           $pab[1] = "/{date}/";
           $pab[2] = "/{blog}/";
           $rab[0] = "<a href='blog-".$r[id].".html'>".stripslashes($r[subject])."</a>";
           $rab[1] = $r[date];
           $rab[2] = stripslashes($r[blog])."<br /><br />";
           eval (" ?>" . preg_replace($pab, $rab, stripslashes($temp)) . " <?php ");
       }
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a written a blog using php and mysql which has a login
I have a blog written in reStructuredText which I currently have to manually convert
I have followed the blog post written by Steve Sanderson at blog.codeville.net/2008/10/14/partial-requests-in-aspnet-mvc . It
I am developing a blog site in asp.net 3.5 with C#. I have written
Update: I have now written a PHP extension called php_ssdeep for the ssdeep C
I have a blog written in Django, and I started using the basic Django
I made a blog database and created some tables in it. I have wriTten
I have a simple blog application written in Python, using Django. I use Git
I've written a PHP script that handles file downloads, determining which file is being
I have written a fairly simple lazy loading proxy class, which I have documented

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.