Basic PHP issues

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

mcraft59
Forum Newbie
Posts: 7
Joined: Wed Jul 09, 2003 6:18 pm
Location: Columbus

Basic PHP issues

Post by mcraft59 »

Hello,

I'm currently making a flash webpage and I'm learning PHP for my guestbook. I'm familiar with java, C, and I've learned a great deal about Flash ActionScript. However, PHP is giving me some problems. I've started small with the tutorials that my book has told me to do. I checked my web host to make sure it has php running http://www.mcraft59.com/version.php and I get the info-screen, but there looks like some extra text at the top and bottom. Is that supposed to be there?
Eitherway I went ahead and did the basic "Hello World" script. My php file consists of a header, followed by a short PHP code in the code, and my output is totally whacked. http://www.mcraft59.com/try.php I can see "hello world" mixed in a bunch of additional junk that I assume my web host is throwing in. Or am I doing something wrong? Below is the code.

try.php
---------------------------
<html>
<head>
<title>Look out world</title>
</head>

<body>
<?php echo 'hello, world!' ?>
</body>

</html>
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Re: Basic PHP issues

Post by McGruff »

mcraft59 wrote:Hello,

Code: Select all

<?php
<html>
 <head>
	<title>Look out world</title>
</head>

<body>
<?php echo 'hello, world!'; ?> // must terminate this line with a semi_colon
</body>

</html>
?>
I'd recommend installing a local server to test your scripts - saves a lot of time ftp'ing up and down.

http://www.hotscripts.com/PHP/Software_ ... tion_Kits/

Also, if you don't have one already, I'd recommend downloading a copy of the php manual from php.net (get the one with user comments - explains much that is not in the bare manual).
Last edited by McGruff on Thu Aug 11, 2005 2:17 am, edited 1 time in total.
mcraft59
Forum Newbie
Posts: 7
Joined: Wed Jul 09, 2003 6:18 pm
Location: Columbus

Post by mcraft59 »

I originally had the ";" after that line of code, but my "O'Reilly" book's example does not have it. Eitherway if it added it doesn't change the result and by adding the "<?php ---- ?>" code to the beginning and end of the file changes my output to a blank page. I think their might be an error with my web host or something. I'm at work right now so when I get home I'll download the php-kit and create a local php server.

Thanks for your help
qartis
Forum Contributor
Posts: 271
Joined: Sat Dec 14, 2002 4:43 pm
Location: BC, Canada
Contact:

Post by qartis »

The last command in a block of <?php doesn't need a semicolon, but it's a good habit to include it anyway.

What happens when you have a PHP script like this:

Code: Select all

<?php
echo "Hello";
?>
That would work on any version of php, and any settings in php.ini.
mcraft59
Forum Newbie
Posts: 7
Joined: Wed Jul 09, 2003 6:18 pm
Location: Columbus

Post by mcraft59 »

I tried that code and I got a blank screen once again :(
http://www.mcraft59.com/work.php



work.php
---------------

<?php

echo "Hello";

?>
qartis
Forum Contributor
Posts: 271
Joined: Sat Dec 14, 2002 4:43 pm
Location: BC, Canada
Contact:

Post by qartis »

Usually the *only* time PHP ever gives me a blank screen is if error_reporting is off, and there's a fatal parse error. If you View>Source on the blank page, is there nothing at all, or is there <HTML><HEAD></HEAD></HTML>?
Last edited by qartis on Fri Jul 11, 2003 2:46 pm, edited 1 time in total.
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

He provided a link to the page, the source code is entirely blank.
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

are you sure php is set up on the server?
qartis
Forum Contributor
Posts: 271
Joined: Sat Dec 14, 2002 4:43 pm
Location: BC, Canada
Contact:

Post by qartis »

He provided a link to the page, the source code is entirely blank.
Sorry, my dns server refused to resolve his domain, so I couldn't see it :oops:
mcraft59
Forum Newbie
Posts: 7
Joined: Wed Jul 09, 2003 6:18 pm
Location: Columbus

Post by mcraft59 »

I viewed the source code for the files from IE and all I get is the html tags. I don't know why it will not display the simple echo message. Apparently PHP is enabled on the server because of http://www.mcraft59/version.php shows that it is installed. Yet no other php scripts will run on the server. Open to any last suggestions on this.
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

when i get the info instead of the following i can try to help


The page cannot be displayed
The page you are looking for is currently unavailable. The Web site might be experiencing technical difficulties, or you may need to adjust your browser settings.

--------------------------------------------------------------------------------

Please try the following:

Click the Refresh button, or try again later.

If you typed the page address in the Address bar, make sure that it is spelled correctly.

To check your connection settings, click the Tools menu, and then click Internet Options. On the Connections tab, click Settings. The settings should match those provided by your local area network (LAN) administrator or Internet service provider (ISP).
If your Network Administrator has enabled it, Microsoft Windows can examine your network and automatically discover network connection settings.
If you would like Windows to try and discover them,
click Detect Network Settings
Some sites require 128-bit connection security. Click the Help menu and then click About Internet Explorer to determine what strength security you have installed.
If you are trying to reach a secure site, make sure your Security settings can support it. Click the Tools menu, and then click Internet Options. On the Advanced tab, scroll to the Security section and check settings for SSL 2.0, SSL 3.0, TLS 1.0, PCT 1.0.
Click the Back button to try another link.



Cannot find server or DNS Error
Internet Explorer
mcraft59
Forum Newbie
Posts: 7
Joined: Wed Jul 09, 2003 6:18 pm
Location: Columbus

Post by mcraft59 »

lol, wrong link. Forgot the ".com"


Source Code:

http://www.mcraft59.com/version.php
version.php
--------------
<?php phpinfo() ?>



http://www.mcraft59.com/try.php
try.php
-----------------
<html>
<head>
<title>Look out world</title>
</head>

<body>
<?php echo 'hello, world!'; ?>
</body>

</html>
mcraft59
Forum Newbie
Posts: 7
Joined: Wed Jul 09, 2003 6:18 pm
Location: Columbus

Post by mcraft59 »

omfg I got it working I think. Damn web host stuck these "\par" in everyline of my code plus some header. So I went in and re-editted my php code and deleted all their server side added junk.
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

hmmm... why the "{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}} {\*\generator Msftedit 5.41.15.1503;}\viewkind4\uc1\pard\f0\fs20 " at the top?

i have "hello, world! } " displayed by the second link (now)

i think there might be something wrong int he installation
macewan
Forum Commoner
Posts: 97
Joined: Mon Jul 07, 2003 8:27 pm

Post by macewan »

are you using notepad or microsoft word to create this file?
Post Reply