August 21, 201214 yr 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 August 21, 201214 yr by Fran Haselden
August 21, 201214 yr 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?
August 21, 201214 yr 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 The above file works fine when running locally but just not when I upload it :/ Edited August 21, 201214 yr by Fran Haselden
August 21, 201214 yr 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 August 21, 201214 yr by sash_oo7
August 21, 201214 yr 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 Edited August 21, 201214 yr by AlexsDesign
August 21, 201214 yr 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
August 21, 201214 yr 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 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?
August 21, 201214 yr 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
August 21, 201214 yr 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
August 22, 201214 yr 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 August 22, 201214 yr by Pete Prosper
August 22, 201214 yr 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!
August 22, 201214 yr 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