theme call from database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
goneinsane
Forum Newbie
Posts: 6
Joined: Fri Oct 09, 2009 2:59 pm

theme call from database

Post by goneinsane »

Hello,

I am very new and just learning PHP. I have a question. I would like the header file to change depending on the theme the user has. I have made a field on another page where the user types in the name of the theme they want to use. I typed in "default" and it's showing in the database as being there. The original looked like this:

Code: Select all

require_once("themes/Default/header.php");
but I want to change it so it calls the theme name from the database.
I've tried:

Code: Select all

require_once("themes/" . $a1[TemplateName] . "/header.php");
but it didn't work so I also tried:

Code: Select all

require_once("themes/$a1[TemplateName]/header.php");
Can anyone help me with any other suggestions. I feel so dumb but this is the only way I will learn.

Thank you.
User avatar
desperado
Forum Commoner
Posts: 46
Joined: Wed Dec 10, 2008 8:49 am

Re: theme call from database

Post by desperado »

First of all, it's always a good idea to wrap your keys in single quotes to avoid using reserved keyword.

$a1['TemplateName']

Did you create the appropriate template folder and associated files?

Code: Select all

require_once("themes/" . $a1['TemplateName'] . "/header.php");
 
should work.

Do you get an error? Please explain.
goneinsane
Forum Newbie
Posts: 6
Joined: Fri Oct 09, 2009 2:59 pm

Re: theme call from database

Post by goneinsane »

Warning: require_once(themes//header.php) [function.require-once]: failed to open stream: No such file or directory

Still not working.
User avatar
desperado
Forum Commoner
Posts: 46
Joined: Wed Dec 10, 2008 8:49 am

Re: theme call from database

Post by desperado »

it's not pulling any data from the database.

either there is nothing in the database, or you have an error in your query.
goneinsane
Forum Newbie
Posts: 6
Joined: Fri Oct 09, 2009 2:59 pm

Re: theme call from database

Post by goneinsane »

It's defiantly in the database and the form where I can change it is working great.
It must have something to do with the way I am calling it from the database.

This is what it is named on the form $a1[TemplateName]. Is it possible that it's name is being changed somewhere else?
From in the database, is it possible to see how it should be called?
goneinsane
Forum Newbie
Posts: 6
Joined: Fri Oct 09, 2009 2:59 pm

Re: theme call from database

Post by goneinsane »

There must be a way to check the cell in mysql to see how it can be called from the website.
Post Reply