Beginner question
am 25.08.2009 07:16:02 von mike bode
I am trying to use PHP on my web site I am developing now. I have installed
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 example:
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 that
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
an idea?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Beginner question
am 25.08.2009 16:47:28 von Ashley Sheridan
On Mon, 2009-08-24 at 23:16 -0600, mike bode wrote:
> I am trying to use PHP on my web site I am developing now. I have installed
> 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 example:
>
> 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 that
> 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
> an idea?
>
>
Yes, this is not how you use PHP! PHP isn't embedded in HTML, it's
actually the other way round.
You should make the main page a .php page and from there you can include
the necessary HTML parts like so:
include "includes/header.html";
// body code here
include "includes/footer.html";
?>
Thanks,
Ash
http://www.ashleysheridan.co.uk
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: Beginner question
am 25.08.2009 16:55:10 von abdulazeez alugo
--_35b5bb4b-15e5-4a15-b73c-42e52ca9f54c_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
> To: php-general@lists.php.net
> From: mikebode1@hotmail.com
> Date: Mon=2C 24 Aug 2009 23:16:02 -0600
> Subject: [PHP] Beginner question
>=20
> I am trying to use PHP on my web site I am developing now. I have install=
ed=20
> Apache 2.2 and PHP 5.2. My problem is that I can execute PHP code embedde=
d=20
> in my HTML code=2C but I can't execute the same cose when I put it into a=
=20
> separate .php file that i then call from within the html code. for exampl=
e:
>=20
> I have a html file with
>=20
>
>
> echo "Printing with php"=3B
> ?>
>
>=20
> and it works fine.
>=20
> When I take out the php code and put it inot a file pp.php=2C and I call =
that=20
> file with my browser ("localhost/pp.php")=2C it works=2C too.
>=20
> But when I change the html code to:
>=20
>
>
>
>=20
> I get a blank page. this is probably something really stupid=2C but I hav=
e=20
> been wrecking my head for days now=2C and I can't figure it out. anybody =
has=20
> an idea?=20
>=20
Hello Bode=2C
You obviously purposefully asked your browser not to parse you php code. Yo=
u are linking to a javascript instead of a php file. It's this simple=3B if=
you are create a .php file and u wish to incorporate it in your html code=
=2C you should use a function called include()=3B. Simply try something lik=
e:
Let me know what u get from that.
Alugo Abdulazeez
Serving you from Nigeria.
http://www.frangeovic.com
____________________________________________________________ _____
With Windows Live=2C you can organize=2C edit=2C and share your photos.
http://www.microsoft.com/middleeast/windows/windowslive/prod ucts/photo-gall=
ery-edit.aspx=
--_35b5bb4b-15e5-4a15-b73c-42e52ca9f54c_--
Re: Beginner question
am 25.08.2009 16:59:44 von mike bode
Well, as I said: Beginner ...
I am actually trying to implement some html code that I found on the web,
which uses php (see:
http://www.dynamicdrive.com/dynamicindex4/php-photoalbum.htm ). They use the
method I tried to call a function php and then display a "photo album".
Well, that doesn't work. I am just getting a blank page when I follow their
instructions. So I thought I try to follow the trail and see where it ends.
But how do I do that? I was attempting to do so with the script that I
posted, but apparently that doesn't work. So, how do I find out why my
installation does not process the html code that I have posted a link to
above? How would I implement that on my web site?
Thanks.
"Ashley Sheridan" wrote in message
news:1251211648.2799.46.camel@localhost...
> On Mon, 2009-08-24 at 23:16 -0600, mike bode wrote:
>> I am trying to use PHP on my web site I am developing now. I have
>> installed
>> 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
>> example:
>>
>> 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
>> that
>> 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
>> an idea?
>>
>>
> Yes, this is not how you use PHP! PHP isn't embedded in HTML, it's
> actually the other way round.
>
> You should make the main page a .php page and from there you can include
> the necessary HTML parts like so:
>
>
> include "includes/header.html";
>
> // body code here
>
> include "includes/footer.html";
> ?>
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: Beginner question
am 25.08.2009 20:15:22 von Arno Kuhl
-----Original Message-----
From: mike bode [mailto:mikebode1@hotmail.com]
Sent: 25 August 2009 07:16 AM
To: php-general@lists.php.net
Subject: [PHP] Beginner question
I am trying to use PHP on my web site I am developing now. I have installed
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 example:
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 that
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
an idea?
--
I presume your html/php code is in a file with a .php extension? If not then
change the extension to "php" because most other webservers won't parse php
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
tags.
The php script you're trying to include in your html code with javascript
would presumably echo out the javascript code that ends up in your html
page, but if you don't know php then you're trying to run before you can
walk.
If possible try to see what javascript code is being generated (echoed) by
the php script and put it in a normal .js file (e.g. pp.js) and then use it
like any other javascript file
This isn't always possible because often php is used to decide what
javascript to output (otherwise why bother). If you have to use php to
generate your javascript code then start with small steps - try echoing some
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 back
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.
Cheers
Arno
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Beginner question
am 25.08.2009 20:54:15 von TedD
At 11:16 PM -0600 8/24/09, mike bode wrote:
>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 an idea?
Mike:
Here's an idea -- try this:
http://sperling.com/examples/include-demo/
If you complete that (a hour or so, not days), you'll have a much
better idea of what this is all about.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Beginner question
am 25.08.2009 22:38:01 von mike bode
Thanks.
I will surely do that.
In the meantime I have found out that it really is not a problem with the
code. I uploaded the (non-functioning code) from my PC to a public web
server, and lo and behold, the code works.
It thus appears that there is something wrong with my php-apache setup.
Now that's a whole other issue that I now need to try to solve. Any
suggestions where to start?
Thanks.
"tedd" wrote in message
news:p06240806c6b9e3571433@[192.168.1.102]...
> At 11:16 PM -0600 8/24/09, mike bode wrote:
>>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
>>an idea?
>
> Mike:
>
> Here's an idea -- try this:
>
> http://sperling.com/examples/include-demo/
>
> If you complete that (a hour or so, not days), you'll have a much better
> idea of what this is all about.
>
> Cheers,
>
> tedd
>
> --
> -------
> http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Beginner question
am 25.08.2009 22:45:07 von mike bode
I see. PHP runs on the server and cannot directly interact with my browser,
only through Javascript. So I can use javascript to "trigger" a php script,
which does something on the server, and returns something to javascript on
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?
Thanks.
""Arno Kuhl"" wrote in message
news:A6C65A0610F9485787E31F7161CB7DC3@point01...
> -----Original Message-----
> From: mike bode [mailto:mikebode1@hotmail.com]
> Sent: 25 August 2009 07:16 AM
> To: php-general@lists.php.net
> Subject: [PHP] Beginner question
>
> I am trying to use PHP on my web site I am developing now. I have
> installed
> 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
> example:
>
> 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
> that
> 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
> an idea?
>
> --
>
> I presume your html/php code is in a file with a .php extension? If not
> then
> change the extension to "php" because most other webservers won't parse
> php
> 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
> tags.
>
> The php script you're trying to include in your html code with javascript
>
> would presumably echo out the javascript code that ends up in your html
> page, but if you don't know php then you're trying to run before you can
> walk.
>
> If possible try to see what javascript code is being generated (echoed) by
> the php script and put it in a normal .js file (e.g. pp.js) and then use
> it
> like any other javascript file
>
> This isn't always possible because often php is used to decide what
> javascript to output (otherwise why bother). If you have to use php to
> generate your javascript code then start with small steps - try echoing
> some
> 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
> back
> 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.
>
>
> Cheers
> Arno
>
>
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Beginner question
am 25.08.2009 23:17:43 von TedD
At 2:45 PM -0600 8/25/09, mike bode wrote:
>I see. PHP runs on the server and cannot directly interact with my
>browser, only through Javascript.
Kind of.
PHP runs on the server and can create html, css, javascript et al.
However, PHP will complete it's task before the browser see's
anything. Once the browser see's the code, it's up to the browser to
interpret and run html, css, and javascript.
If your html is a form (i.e., submit), or you have javascript
running, then either of those can trigger a php script on the server
to run which can repeat the process in generating new html, css, and
javascript (if needed). Normally, javascript is not generated by PHP,
but it can be.
Using javascript to trigger an event certainly works IF javascript is
turned on by the user's browser. However, this is something that you
have absolutely no control over. A user can turn javascript ON/OFF at
their discretion. You see, many people turn javascript off because of
security concerns -- and those concerns are not without foundation.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php