|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today! |
|
#1
|
|||
|
|||
|
Beginner needing help with a problem.
As the subject states, I'm a beginner in PHP, and what I know I have taught myself. So in other words if what I'm trying to do is just, completely and totatlly wrong, you know why. Basicly I'm having trouble with a script I'm writing to be a generic website backend. It uses PHP and MySQL. The SQL database (at the moment) has two tables, one that holds the site's template, and another that holds the unique part of the code for each individual page and an ID. There is an index page that calls and echos the code field of the template. The code of the template in turn calls and echos the individual pages based on the $show variable. So basicly its a code, that calls another set of code, that calls another set of code, which is where my trouble is. The reason I dont' just have the template page static is so that it can be edited via online form through the site's backend. The problem I have though is that the code in the templete, when called to the index page, doesn't registar as PHP code. Rather it just prints the code as if there were no tags around it. Why is this? is it possible to put php script inside an SQL database, echo it, and expect it to run? Let alone stack 3 layers of this as I'm attempting to do? If you need anymore information I'd be more then happy to apply with what you need. I can't link to where the code is on my webserver because the directory is secure. But I'd find it acceptable to post parts of the code if nesscary. Also contact over e-mail and ICQ messages is welcome. Thanks in advance for providing a place to ask for help. As of yet in teaching myself PHP if I stuck with it long enough I've been able to figure out my own problems, but this one really has me jumping through hoops. Thanks Again, -MuuTuwon |
|
#2
|
|||||
|
|||||
|
RE: Beginner needing help with a problem.
Try something like this:
php Code:
All you need to do is in your template, where there page code should be inserted, add: <-insert page here-> Really, the eval() function is the whole heart of the thing.... |
|
#3
|
|||
|
|||
|
RE: Beginner needing help with a problem.
I like the way how that works. Matt maybe you could do a tutorial on how to do it?
|
|
#4
|
|||
|
|||
|
RE: Beginner needing help with a problem.
I've put it on my list
|
|
#5
|
|||
|
|||
|
Thanks
Thanks for the help, unfortinatly it didn't work out but I think that may be because of my own inabilty to understand the function correctly.
I had to change several parts of the code to fit my table structure in SQL, I don't know how much of an effect that would have on it but I'm including the code this time to see if I've done something wrong. And also, what exaclty does the eval() function do? just for personal reference so I may be able to use it in the future? <?php $db = mysql_connect('www.doomland.net','****','****') or die("could not connect to database"); mysql_select_db('test') or die("could not select database"); $query = "SELECT * FROM sitemain WHERE id ='template'"; $row = mysql_fetch_array(mysql_query($query)); $template = $row['code']; $query = "SELECT code FROM sitemain WHERE id='$show'"; $row = mysql_fetch_array(mysql_query($query)); $page = $row['code']; $display = str_replace("<-insert page here->",$page,$template); eval($display); ?> Any suggestions welcome. -MuuTuwon |
|
#6
|
|||
|
|||
|
RE: Beginner needing help with a problem.
Do you mean that you store variables e.g. $variable in a MySQL database?
Because if you do, then PHP will think that it is just text! The only thing you could do is store numbers instead of variables, and use a string replace to replace the variable with the value! But its pretty pointless. You could try and cut out the middle script, you said that it was linked between 3 script! Thanxs Christoph Neal London, UK Chris@n-12.net www.n-12.net |
|
#7
|
|||
|
|||
|
RE: Beginner needing help with a problem.
Pay NO attention to what i just said!
|
|
#8
|
|||
|
|||
|
RE: RE: Beginner needing help with a problem.
Quote:
how long is your list now matt? |
|
#9
|
|||
|
|||
|
RE: Beginner needing help with a problem.
Too long
|
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > Beginner needing help with a problem. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|