I see. PHP runs on the server and cannot directly interact with my browser,
my machine, which can then be used to do something on my browser.
However, as I just said in this thread, I found out that the code is
actually working, just not on my machine. I uploaded the code to a public
web server (www.bestrmvacation.com/album.htm, if you want to check it out),
and it works there. But not on my computer. There must be something broken
with my PHP or Apache Installation. However, when I run a PHP script that
calls phpinfo(), it works fine. Any idea where this might go wrong?
BTW, I am using Expression Web to develop the web site. Could that have
anything to do with it?
""Arno Kuhl"" <ak...@telkomsa.net> wrote in message
From: mike bode [mailto:mikebo...@hotmail.com]
Sent: 25 August 2009 07:16 AM
Subject: [PHP] Beginner question
I am trying to use PHP on my web site I am developing now. I have
Apache 2.2 and PHP 5.2. My problem is that I can execute PHP code embedded
in my HTML code, but I can't execute the same cose when I put it into a
separate .php file that i then call from within the html code. for
I have a html file with
echo "Printing with php";
and it works fine.
When I take out the php code and put it inot a file pp.php, and I call
file with my browser ("localhost/pp.php"), it works, too.
But when I change the html code to:
I get a blank page. this is probably something really stupid, but I have
been wrecking my head for days now, and I can't figure it out. anybody has
I presume your html/php code is in a file with a .php extension? If not
change the extension to "php" because most other webservers won't parse
code in a html file. If you have a .php file you can mix html and php the
way you described, and you can put your php code between the <?php and ?>
page, but if you don't know php then you're trying to run before you can
the php script and put it in a normal .js file (e.g. pp.js) and then use
This isn't always possible because often php is used to decide what
simple js code in your pp.php (like an alert) just so you can see how it
works. Once you get that working you can move on to more useful things.
To illustrate, what's actually happening with the code you have at the
moment is this:
The browser parses the initial html code and finds
And sends a request back to the server for pp.php
The server runs pp.php and send the output generated by the php script
to the browser,
so effectively the browser ends up with
Obviously that isn't going to work. Hopefully you can now see what the
problem is and how to fix it.
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php