Forum Moderators: coopster
I just put up a Drupal site, which is a PHP driven Content Management system.
I would like to create a block (a block of html that can contain php to be placed on predesignated pages) where I use PHP to call a Perl script.
at the present time, I am using javascript, but I would like to know how to do this in PHP.
The javascript that I am currently using executes a Perl script that picks up a random post from a forum (perl driven forum), formats a "teaser" with a link to that post, and displays it on the webpage containing the javascript.
How would I do the same thing using PHP?
I am on shared hosting.
Thanks.
echo [url=http://www.php.net/file-get-conents]file_get_contents[/url]('http://www.example.com/path/to/script');
Make sure to use the URL version of the path so that the script is parsed first.
<div><?php
echo [url=http://www.php.net/file-get-contents]file_get_contents[/url]('http://www.mysite.com/cgi-bin/av/rpost_arc.pl?js=5');
?></div> and I get this when I try to execute it
Parse error: syntax error, unexpected '[' in /home/mysite/public_html/includes/common.inc(1537) : eval()'d code on line 2 ?
am I supposed to call "common.inc" in this block of php code that I placed in the middle of this html page?
I tried using this method previously, tried their "example 3":
[devzone.zend.com...]
but my host didn't have this php extension installed, and when I asked for it, they wouldn't do it. They said they don't because
it's not really practical for us to install PHP extensions on our shared servers - every time the server is updated, it wipes out any custom PHP configuration, so the extension would automatically remove itself after a random amount of time - possibly a few days, weeks etc. That's probably not good if you'd be using the script on a live site.
I am on shared hosting and don't know how to install this extension just on my site.. so, I thought I would try to find another method.
the new block of "php within HTML" looks like this:
<div>
<?php
$ch = curl_init();
$timeout = 0; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, 'http://www.owenfoundation.com/cgi-bin/av/rpost_arc.pl?js=5');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
echo $file_contents;
?>
<em><span style="font-size: 12px">random posts</span></em></div>
and I'm getting the output... but, it is enclosed with this:
document.write('Another View Archive
Total Number of Archived Posts = 11433--------------------------------------------------------------------------------
Random Posts:*Maddy, here is a link... Link in Post - Lynne
*Salmon Bill! Link in Post - Cheryl
*Good thing I don't.... - Karen
*Bill-what a joy... - Nancy A+ ns
*Please do continue applause - Maggie
');
random posts
how can I remove the "document write('...')" from the code?