Your Cart
No products in the cart.

This simple code is from PHP & MySQL: Novice to Ninja, 6th Edition
That’s the only line of code at phpoop.life/name.html/.
The name.php file contains the following:
I tried to create a virtual server, but my Intel CORE 15 doesn’t support it.
Why does it download the php file rather than displaying the page???
Your help is much appreciated. I really want to get on with this book.
Should be that. If it downloads the PHP file, that’s most likely because you didn’t install it correctly.
well that’s embarrassing! Seems i titled my website apprpriately :slight_smile:.
Made the change, “<?php” and cleared caches in my browsers, but they still want to grab the local name.php file and send it to the download directory rather than open the name.php web page.
What to do?
It sounds like you are trying to open it as a file instead of a web page.
In other words, when you navigate to the file by having the path to it in your browsers address bar, eg. http://localhost/somefile.php the server should give the browser the output of the file not it’s text content.
I can think of two things to check. The more obvious, that the file has the “.php” file extension so PHP will know to parse it. The more involved, that your set-up is correct. i.e. your localhost is running and it knows where to find the PHP engine.
How did you set up your localhost server, XAMPP, or other “packaged environment”, Apache, PHP separately with the path added to your system variables, the path to PHP in Apache’s httpd.conf file inside a Virtual Machine? etc.
To expand on the above - running a PHP script requires that you have some kind of server software running in a place you can access it. So if you’re just finding the PHP script inside Windows File Explorer and double-clicking it, the default isn’t usually to run it via your server - on my box it’s to open it to edit. You need to open the browser and open it in the address bar.
Thanks for your suggestions above. All three touched on what I think the problem is.
It came to me as I was brushing my teeth before I went to bed last night, which tells me I should think before I speak (post). i haven’t set up my host server php.
I was wanting to create the website from scratch rather than use a CMS. But as I intend to use what I learn from this book on Wordpress site with a php plugin, I’ll go ahead and install Wordpress and see how that works.
I need to learn more about host servers and their relationship to websites.
I need to learn more about host servers and their relationship to websites.
Just consider where the code is running. HTML and JavaScript tends to run in the browser, so the browser doesn’t usually need anything else to make it work, whereas PHP runs on the server, so you need to have one somewhere, whether it’s local or not.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.
Powered by Discourse, best viewed with JavaScript enabled