Jump to content

Recommended Posts

Hi guys,

 

I'm new to PHP and I hope this is the right place for this query.  If not then I offer my apologies.

 

I've got a Virgin Media account that supposedly supports PHP but I'm having difficulty getting a script to run.  I've uploaded a copy of their example script to my htdocs folder, however when I go to the URL in my browser the script doesn't run; instead it prompts me to download it.

 

I've searched the Internet and the only "solution" I can find to this problem is to check that PHP is installed correctly on the server (not an option in this case as Virgin Media & co. deal with that).  In any case I'm sure that PHP is installed and functioning correctly because their example script runs under their own URL on (presumably) the same server:

 

Virgin Media example: http://www.anfield.pwp.blueyonder.co.uk/scripts/test-php.php

My website: http://www.weyoun47.pwp.blueyonder.co.uk/scripts/test-php.php

 

I've already tried various combinations of permissions on the PHP file (read, write, execute etc.) without success.

 

Does anyone have any suggestions as to what might be going on here and how to get this thing working?

 

Thanks in advance.

-Weyoun47.

Link to comment
https://forums.phpfreaks.com/topic/180620-basic-php-problem/
Share on other sites

Are you working online or in a local environment? If local...

 

I'm a beginner too but I've had this problem also. Whenever I had this happening it usually mean't that my WAMP or equivalent was not installed properly, or that it's services simply wasn't turned on. This happened a lot with Google Chrome.

 

Just check that WAMP / XAMP  or whatever you're using is running.

Link to comment
https://forums.phpfreaks.com/topic/180620-basic-php-problem/#findComment-952925
Share on other sites

I'm working entirely online.  For some reason the server is returning something different (i.e. the raw PHP source) when I click the second link than when clicking the first (in which the server correctly executes the phpinfo command and returns output accordingly).  The two scripts are identical and they're both on the same server.  So why does one work and the other not?

Link to comment
https://forums.phpfreaks.com/topic/180620-basic-php-problem/#findComment-952928
Share on other sites

You got caught using the lazy-way short open tags <? that waste several magnitudes more time than they ever saved by not typing the three characters php a few times on any page.

 

I didn't write the script.  I downloaded it from the ISP who provide me with my webspace and then uploaded directly to my webspace.  The ISP offered it as an example, so there's no reason that I can see that it shouldn't work.  The PHP script in the first link given in my first post is identical to the one on my own webspace (second link), so why does one work and the other doesn't?

Link to comment
https://forums.phpfreaks.com/topic/180620-basic-php-problem/#findComment-953202
Share on other sites

Just because your web host posted a code example that is using a feature that can be turned off and is therefore not portable between different server configurations, does not mean that you should blindly follow along.

 

If you always use full <?php tags, your php code will always be seen as php code.

Link to comment
https://forums.phpfreaks.com/topic/180620-basic-php-problem/#findComment-953214
Share on other sites

I didn't write the script.

 

That does not matter. As soon as you put any code that you find or write into a file on your server, it becomes your code. You are at that point responsible for what it is and what it does or if it contains something that is not compatible with either your server or your server configuration. Which is generally why it is a better idea to write your own code that does what you want it to, than to just copy/paste code that someone else wrote.

Link to comment
https://forums.phpfreaks.com/topic/180620-basic-php-problem/#findComment-953629
Share on other sites

That does not matter. As soon as you put any code that you find or write into a file on your server, it becomes your code. You are at that point responsible for what it is and what it does or if it contains something that is not compatible with either your server or your server configuration. Which is generally why it is a better idea to write your own code that does what you want it to, than to just copy/paste code that someone else wrote.

 

OK, I've updated the script to use the correct opening tag, <?php.

 

It still doesn't work.

Link to comment
https://forums.phpfreaks.com/topic/180620-basic-php-problem/#findComment-953694
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.