Re: Using echo to run separate PHP script from HTML [message #179920 is a reply to message #179918] |
Wed, 19 December 2012 16:04 |
The Natural Philosoph
Messages: 993 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 19/12/12 12:30, P E Schoen wrote:
> I am able to access this script using a simple HTML file if I do it with
> a direct <img src="goalgraph.php" />. But when I try to do so using PHP
> within the HTML, using echo, it does not work. I tried renaming the file
> php and adding the "AddType application/x-httpd-php .htm" to a .htaccess
> file, but no joy. Here is what I have:
>
> <html>
> <body>
> Goalgraph
> <hr />
> <?php
> //echo '<img src="' . "goalgraph.php" . '" />' . "\n";
well that's plain wrong ..you have too much of a buggers muddle of quotes.
printf makes things easier..
try
printf ('<img src="%s" />\n', 'goalgraph.php');
>
> $datafile = "goalgraphdata.txt";
> if( file_exists($datafile) ) {
> echo "File Found\n";
> $df = fopen( $datafile, "r" ) or die( "File Error" );
> $current = trim(fgets( $df ));
> $goal = trim(fgets( $df ));
> $height = trim(fgets( $df ));
> $width = trim(fgets( $df ));
> fclose( $df );
>
> echo '<img src="' . htmlspecialchars("goalgraph.php?cur=" .
> urlencode($current) . "&goal=" . urlencode($goal) .
> "&width=" . urlencode($width) . "&height=" . urlencode($height) ) .
> '" alt="Help us achieve our goal"' . " /> \n";
> }
> else
> echo "File not found\n";
> ?>
> <hr />
> <img src="goalgraph.php" />
> </body>
>
> </html>
>
> It's been a long time since I have done anything with PHP or HTML for
> that matter, so I'm quite rusty, and it may be something simple. Any
> help will be most kindly appreciated.
>
> Thanks!
>
> Paul
--
Ineptocracy
(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
|
|
|