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
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Sep 11, 2005 7:34 am
SSI will not parse inside of php unless SSI knows it can, but then it ceases to be php...
Could you start using the code posting tags like
nparekh
Forum Commoner
Posts: 31 Joined: Fri Aug 05, 2005 2:35 am
Post
by nparekh » Sun Sep 11, 2005 7:18 pm
Hi feyd
Thanks for your reply.
I'd love to use
Code: Select all
but have no idea how to!
If you could possibly give an example I'll try it out immediately.
I presume you mean useCode: Select all
instead of <?php but where do I use the
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Sep 11, 2005 7:31 pm
read the first link "How to Post Code on DevNetwork" in my signature..
nparekh
Forum Commoner
Posts: 31 Joined: Fri Aug 05, 2005 2:35 am
Post
by nparekh » Sun Sep 11, 2005 7:53 pm
Thanks feyd
Ok heres my results now-the code below is for a file called rotate.php:
Code: Select all
<?php
$art = mt_rand(0, 50);
if($art == "0") {
include("article.inc");
} else {
include("article" . $art . ".inc");
}
?>
The results are ok when I open the rotate.php file in a browser as displayed below:
However when I use this code on my main site nothing appears on my main site:
Code: Select all
<!--#include virtual="rotate.php-->
I have tried with the <php> tags as well but because my host only supports SSI I am just getting a blank space where the results (test.txt etc should be displayed)
Any advice please?
Nikhil
timvw
DevNet Master
Posts: 4897 Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium
Post
by timvw » Sun Sep 11, 2005 7:56 pm
Might want to add a
shebang with the right path to the php executable in your rotate.php file
nparekh
Forum Commoner
Posts: 31 Joined: Fri Aug 05, 2005 2:35 am
Post
by nparekh » Sun Sep 11, 2005 8:25 pm
Hi Tim
Thanks for replying.
When I open the rotate.php in a browser I get the files to rotate. However.............
I added the following to the php file rotate.php:
Code: Select all
#!/home/nparekh/public_html/mortgage
<?php
$art = mt_rand(0, 50);
if($art == "0") {
include("test.txt");
} else {
include("test" . $art . ".txt");
}
?>
The code on the main website is in a file and the code is as follows:
Code: Select all
<!--#include virtual="rotate.php-->
Still get a blank space where results should go - so sorry for the hassles!
Thanks again
Nikhil
timvw
DevNet Master
Posts: 4897 Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium
Post
by timvw » Mon Sep 12, 2005 3:19 am
nparekh wrote: Code: Select all
#!/home/nparekh/public_html/mortgage
Ok, you haven't read (or understood) the links i provided. You would need to add the path to the php interpreter (not the scripts). For example if php-cli.exe is in c:/php you would need !/c:/php/php-cli.exe. On a unix webhost, the interpreter is usually at /usr/bin, /usr/local/bin, .. ("which php" in a shell will give a good hint)