Page 1 of 1

theme call from database

Posted: Fri Oct 09, 2009 3:15 pm
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.

Re: theme call from database

Posted: Fri Oct 09, 2009 3:39 pm
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.

Re: theme call from database

Posted: Fri Oct 09, 2009 3:44 pm
by goneinsane
Warning: require_once(themes//header.php) [function.require-once]: failed to open stream: No such file or directory

Still not working.

Re: theme call from database

Posted: Fri Oct 09, 2009 3:49 pm
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.

Re: theme call from database

Posted: Fri Oct 09, 2009 7:27 pm
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?

Re: theme call from database

Posted: Mon Oct 12, 2009 11:31 pm
by goneinsane
There must be a way to check the cell in mysql to see how it can be called from the website.