![]() |
|
#1
|
|||
|
|||
uisng php to display phpRight so i've managed to read and display my menus of my site from a textfile, using php to dispaly the data in html format. Now I recently tried to add a poll to my one menu. This involves including an external php file. SO I enter this into my menu textfile:
PHP Code:
But when I refresh my website, the contents of the textfile are display exact. Meaning when I view the source of the output of the webpage, everything is in html format, even for that php I entered into the textfile. IE: This is what a part of the menu looks like (in html!!): HTML Code:
Last edited by dsmith : 09-May-2004 at 07:33.
Reason: Please use syntax highlighting when posting
|
|
#2
|
||||
|
||||
|
Are you still using fopen() and friends to include this textfile?
__________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#3
|
|||
|
|||
|
yes I do and including the text file works fine. The problem is, the php code within the textfile does not want to execute.
|
|
#4
|
|||
|
|||
|
ANybody?
Perhaps when I store the php in the textfile, it should be stored as follows: <?php print "this is text generated by php"; ?> Will it execute then? |
|
#5
|
||||
|
||||
|
Oops! Sorry Dopee, I was a bit distracted this week on some other things and I didn't mean to ignore this thread.
Anyway, my last reply should have given you a clue why it doesn't work... So back to the issue; let's assume you had a regular web page named... say; new-1.php. Inside this PHP file you have this code: PHP Code:
Now since you're using fopen() and friends to READ in the contents of lmenu.txt, it doesn't really parse ANY PHP code inside lmenu.txt! To fix this you can do 2 things; you could use the function eval() to parse the contents off lmenu.txt AFTER it's read in by showmenu.php OR... just modify the example above to something like this: PHP Code:
But remember, if that poll script is doing anything with headers and cookies, you're going to need the help of ob_start() and friends... __________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#6
|
|||
|
|||
|
I see now!
So instead of opening the textfile and printing it line by line, I use the include_once(); function and the php within the textfile is executed. Thanx man big help ill try it now. |
|
#7
|
||||
|
||||
|
Looks like you finally understood what I was trying to explain. Also, note the last sentence in my last reply. If you find "headers already sent..." errors, simply insert ob_start() to the top of your web page / script (not in the include files), like in the example below and hopefully, any such errors will go away:
PHP Code:
__________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
Recent GIDBlog
A Week in Kuwait by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| php software | dopee | MySQL / PHP Forum | 0 | 04-May-2004 11:26 |
| Optimizing your web server with Turck MMCache for PHP | JdS | Web Hosting Forum | 2 | 07-Jan-2004 07:48 |
| Automate a data change php form | mjfmn | MySQL / PHP Forum | 4 | 20-Oct-2003 09:37 |
| [Linux] Installing PHP --with-mcrypt | JdS | Web Hosting Forum | 0 | 20-Aug-2003 08:40 |
| All the big PHP script collections that matter | jrobbio | MySQL / PHP Forum | 5 | 06-Jun-2003 16:14 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The