FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Using echo to run separate PHP script from HTML
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Using echo to run separate PHP script from HTML [message #179920 is a reply to message #179918] Wed, 19 December 2012 16:04 Go to previous messageGo to previous message
The Natural Philosoph is currently offline  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.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: passing values into javascript
Next Topic: Digest Authentication
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Jul 08 12:50:09 GMT 2024

Total time taken to generate the page: 0.05263 seconds