Unable to get php to display on webpage.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

mypen
Forum Newbie
Posts: 5
Joined: Sun Aug 10, 2003 2:22 am

Unable to get php to display on webpage.

Post by mypen »

Hi all
I am a newbie at php. But I successfully made one. When I go to http://www.mywebsite/folder/folder /thing.php, it does what it is suppose to do. Buy I want in in my webpage and I just cannot figure out how to put the php into the page. Tried and failed, probably because this is my first attempt.
I would appreciate any help.
toms100
Forum Contributor
Posts: 119
Joined: Wed Feb 26, 2003 10:29 am
Location: Bristol,UK

Post by toms100 »

I presume you mean to show the source code? if so this is what you need

Code: Select all

<?php
show_source("yourscript.php");
?>
mypen
Forum Newbie
Posts: 5
Joined: Sun Aug 10, 2003 2:22 am

Post by mypen »

I have tried this but I still can't get it to display. It is quite confusing (and annoying).
Any other tips?
User avatar
skateis2s
Forum Commoner
Posts: 37
Joined: Fri Aug 08, 2003 7:22 am
Location: colorado

Post by skateis2s »

what do you mean

just upload a something.php with any code like this


<?
echo "Hello world.";
?>
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Re: Unable to get php to display on webpage.

Post by JAM »

mypen wrote:Buy I want in in my webpage and I just cannot figure out how to put the php into the page.
I might be totaly lost, but from what I understood...

Code: Select all

<?php
 $background = '#000000';
?>
<html>
 <head>
  <title>
<?php
  echo 'MY HOME!';
?>
   </title>
  </head>
  <body background="<?php echo $background; ?>">

... etc
mypen
Forum Newbie
Posts: 5
Joined: Sun Aug 10, 2003 2:22 am

Post by mypen »

The php does work if I enter http://www.mywebsite/folder/folder /thing.php into my browser--I can see it working.
But I can't see anything if I do this:
<HTML>
<Body>
<?php
show_source("thing.php");
?>
</Body>
</HTML>

What can I being doing so horribly wrong? (Remember I am a newbie)
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

We were all newbies once... =)

Do you do " show_source("thing.php"); " in the file at
http://www.yoursite.com/index.php
or
http://www.yoursite.com/folder/folder/index.php

?
mypen
Forum Newbie
Posts: 5
Joined: Sun Aug 10, 2003 2:22 am

Post by mypen »

My php is located here:
http://mysite.com/folder/thing.php
So how do i write, or rewrite:
<HTML>
<Body>
<?php
show_source("thing.php");
?>
</Body>
</HTML>


So, exactly how do I "show source"?
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

wait. i think your point is you're seeing the source, not what you want printing out.


if so then check your tags against the ini file. <? might be off, as with <% whcih are off by default (i believe)
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

mypen:
Sorry, clueless...
m3rajk wrote:wait. i think your point is you're seeing the source, not what you want printing out.
Well, he's using <?php so it should work neverless...
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

in which case, how much of a newb is he? did he name it .html or .php?
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

How very nice of you.
He stated that he was new at this, so instead of bashing, you should try to help?
toms100
Forum Contributor
Posts: 119
Joined: Wed Feb 26, 2003 10:29 am
Location: Bristol,UK

Post by toms100 »

are you sure your host does php?

what exactly are you trying to do?
colour code the source?
get the php to work? (is it just showing uncompiled code?)
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

JAM wrote:How very nice of you.
He stated that he was new at this, so instead of bashing, you should try to help?
umm. i'm not bashing. if he has it .html it wont be evaluated. like in anything, before you look to see if it's a zebra, make sure it's not a horse.

make sure the basics are covered first. that's what i' trying to do. cover the absolute basics.
the file extension, the ini settings. the simple things that need to be done right. before going after anything that might be elusive.

if you can't see that then you have issues you should go straighten out.

not trying to be holier than thou or anything, but that's the precise attitude you just gave me as well as accusing me of something simply for asking him to check the most basic of things since he stated he's a newb. he reitereated that for a reason.


so get back to the absolute basic and build from there...

that means: what's the extension?
what's the ini settings? (though in this case it SHOULD be moot)
is php even installed?
(if a self install on his own machine, is it installed right?)
what version of php?


the basic things that will allow you to rule out the "i can't see my monitor. no my power cord isn't plugged in" <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> and go on from there. go work in a call up help desk for a month. you'll be suprised at how many people overlook the most logical things. never assume anyone did anything right unless they state something explicitly when asking for help. as soon as i have an issue i assume everything i have is wrong past he last time it worked and ask for help stating what's been done so those giving the help will know what was covered. they will know if something may have been overlooked to ask about it. it's what i expect people to give me and i give to people when looking to help.

just because i'm thurough and to try to avoid the common sense mistakes when trying to help does not mean i'm bashing. that is something that should be clear. i even asked "how much of a newb is he?" meaning how basic do we need to get to be sure all the bases are covered.
mypen
Forum Newbie
Posts: 5
Joined: Sun Aug 10, 2003 2:22 am

Post by mypen »

Okay
Yes php is installed and my monitor is plugged in and on..
My php files work and work fine. I see them work if I enter http://www.mysite.com/folder/test.php in my browser. I refresh screen, and it does what it does.
But I want to add the php to my homepage and not a link to the file. I know the file works because I go to http://www.my....test.php and it works. Since I see it working, then that must mean that the server is properly configged for php.
But I think my problem is that I do not know to add it into my homepage.
So I open up notepad and write this:
<HTML>
<Body>
ADD PHP HERE
</Body>
</HTML>
Then I rename it to html to see if works.

So, what do I have to put where it says ADD PHP HERE. I am just trying out a simple random quote. If I get that to work, then I can figure out the rest. But I just cannot figure that yet.

I understand the frustration newbies cause. I have had a computer for 5 years now. It frustrates me to no end when I ask my wife to shut down the computer and she simply unplugs it from the wall. So please be patient with this newb. Hopefully in a month, I will no longer be a newb but a contributing member to this forum.
Post Reply