Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Creating my first PHP page - server not configured correctly?

Featured Replies

Hi,

 

So I'm attempting to use some PHP for the first time!

 

I uploaded a .php file but found that when I went to view it online it simply 'downloaded' instead. I googled about and it seems this is a problem with my server. I've uploaded a simple phpinfo file to check if it was a problem with my code, but that downloads too.

 

Now I've contacted the company I host with and they have told me that my server is configured for PHP and should work fine... but obviously it doesn't.

 

This is what they sent to me:

 

PHP 5 is part of the server - is on all servers by standard

 

 

Is there something else I should/could be doing at my end before I go ranting to them about how they told me the wrong thing?

 

Help appreciated! Sorry I am all a bit new to this :(

Edited by Fran Haselden

Hi Fran,

 

It's a bit strange that it's trying to download the file rather than show it....

 

I suppose the first couple of questions is:

 

1) Who are hosted with?

 

2) What does the php file contain?

 

3) Are you about to provide a link to this file?

  • Author

Hi Fran,

 

It's a bit strange that it's trying to download the file rather than show it....

 

I suppose the first couple of questions is:

 

1) Who are hosted with?

 

2) What does the php file contain?

 

3) Are you about to provide a link to this file?

 

Hi.

 

1) Daily.com - haven't failed me yet :/

 

2) I uploaded a simple hello world.

 

3) Well if that means what I think it means, sure, you can download it to your hearts content here, just don't expect to view it on the page :p

 

The above file works fine when running locally but just not when I upload it :/

Edited by Fran Haselden

try renaming it to index.php and check if that works

 

if thats so that means ur host may have disabled direct access to files inside folder

 

tizag is good place to learn php

Edited by sash_oo7

It could be that there is a permissions error on the folder, but that shouldn't cause this issue. (EDIT: Sash appears to have beaten me in replying with this! LOL )

Try renaming it to index.php and access it then...

 

BUT there might be something else ... Not sure if this is causing the issue... but I've spotted a syntax error in the file.

 

Current coding:

<!DOCTYPE html>
<head>
<title>Hello World</title>
</head>
<body>

<p>The following code was created by PHP:
<?php print "Hello World! ?>
</p>

</body>
</html>

 

 

Your missing a few tags and not closed off the php print command...

I would advise trying this:

 


<!doctype html>
<html>
<head>
<title>Untitled Document</title>
</head>

<body>
<p>The following code was created by PHP:
<?php print "Hello World!" ?>
</p>
</body>
</html>

 

Hope this helps :D

Edited by AlexsDesign

Fran,

 

Just tried something... and I think there may be an issue generally...

 

Just tried to visit: http://www.haselden.co.uk/james/ and it downloaded a file called "download" to my system.

It has no file extension... and when I open it, I can see an HTML5 document inside.

With likes to "about" "portfolio"...etc...

 

It appears it may not be a problem with your file and a more overall issue.... I

  • Author

It could be that there is a permissions error on the folder, but that shouldn't cause this issue. (EDIT: Sash appears to have beaten me in replying with this! LOL )

Try renaming it to index.php and access it then...

 

BUT there might be something else ... Not sure if this is causing the issue... but I've spotted a syntax error in the file.

 

Current coding:

<!DOCTYPE html>
<head>
<title>Hello World</title>
</head>
<body>

<p>The following code was created by PHP:
<?php print "Hello World! ?>
</p>

</body>
</html>

 

 

Your missing a few tags and not closed off the php print command...

I would advise trying this:

 


<!doctype html>
<html>
<head>
<title>Untitled Document</title>
</head>

<body>
<p>The following code was created by PHP:
<?php print "Hello World!" ?>
</p>
</body>
</html>

 

Hope this helps :D

 

Thanks! Didn't realise there were some errors.

 

So I got rid of the errors and made the hello.php file all correct, uploaded that, still just downloads.

Then I renamed it index.php - same problem.

Then I moved it up a level to the root. Still downloads.

 

Not sure what I'm doing wrong here?

  • Author

Fran,

 

Just tried something... and I think there may be an issue generally...

 

Just tried to visit: http://www.haselden....k/james/ and it downloaded a file called "download" to my system.

It has no file extension... and when I open it, I can see an HTML5 document inside.

With likes to "about" "portfolio"...etc...

 

It appears it may not be a problem with your file and a more overall issue.... I

 

Thanks, yes that sounds like the site I am creating! That's very strange. Essentially I have coded a site in HTML but I need to make it a PHP file in order to have a form within it, yet when I changed the site to .php it just downloaded - maybe it isn't supported on my server then, which makes life very difficult as I am paying for this service and now cannot use it properly :(

talk to ur host :) and tell them ur issues

they should solve it

don't go hard at them just be nice

state them what issues ur having they should be able to solve it

if not change ur host ;)

I'm guessing it was fixed?

 

"http://www.haselden....james/hello.php" functions correctly on my end.

 

Edit: Many developers find it easier to work offline while learning php. What I mean is, there's a pretty well known server package named XAMPP that installs on your system (and also includes php & mysql). That way, you could run your php scripts locally without having to constantly upload them to your host. I could also be used as a way of discovering whether this issue you're having is in fact your host, or if it's simply your error.

Edited by Pete Prosper

  • Author

D'oh.

 

Yes, it's fixed. After I contacted them a second time they told me they hadn't actually 'switched it on'. So now it is switched on. Good ol' customer service.

 

Thanks for your help guys!

  • Author

I'm guessing it was fixed?

 

"http://www.haselden....james/hello.php" functions correctly on my end.

 

Edit: Many developers find it easier to work offline while learning php. What I mean is, there's a pretty well known server package named XAMPP that installs on your system (and also includes php & mysql). That way, you could run your php scripts locally without having to constantly upload them to your host. I could also be used as a way of discovering whether this issue you're having is in fact your host, or if it's simply your error.

 

Yes, I have that already as I was working through PHP tutorial book, so I know to switch that on when working on it, it was more just a problem when I uploaded the new file to the server and it didn't work then!

 

Also, another question... say I'm about to begin working on some PHP on this page (I'm building a contact form), but I haven't actually got a single bit of PHP in there yet... and it's saved as a .php file.

 

It'll still work, won't it? Just plain HTML in a .php file?

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.