Php code giving no results in firefox? [closed] - php

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 10 months ago.
Improve this question
Just started learning Php on my own, and got stuck at the beginning. This is the code I was compiling:
<?php
echo "Hello world!";
echo 6+2;
?>
The problem is that the Php portion isn't displayed in Firefox. Why? Firefox ver. 7.0.1., I am using NetBeans 7, with cygwin.

You said you're accessing the file directly like file:///C:/xampp/htdocs/PhpVjezba1/test1.php
Don't do that, access it via http://localhost/PhpVjexba1/test1.php, provided you have a server installed.
Click Here

Most likely, you haven't installed php on the server yet. Unlike JavaScript and HTML, php is interpreted at the server, and that requires
a webserver (like apache)
a php runtime
php to be configured
The documentation's installation chapter explains how to install php. There are also third-party distributions like XAMPP that try to simplify the installation process.

In the comment you have the problem. You cannot access the file directly.
Start the webserver and run the file "http://localhost/file.php" then the file should work.

Probably a stupid question, but are you running PHP from web server or actually trying to run the file directly in browser?

PHP is never displayed in any web browser, it is executed on a web server, and is used (somewhat) to produce html that is displayed to you're web browser.
Do you have a local browser such as wamp?

Does the output display in other browsers?
Does your page have the .php extension and is your server set to handle php?

Related

How to change a webpage from .html to .php [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I have made a webpage using .html and I would now like to change it to .php so I can connect it to a database. I have changed the file extension to .php but now it just opens the actual code in the browser as opposed to opening the website. I have googled it but all I can find is stuff about installing .php on a server, when I am just trying to open the file on my device. I am using Microsoft Edge if that matters. What do I do?
First of all, what you have to understand is php is a server side language whereas html is a client side language. As you might already know, html can be directly interpreted by browser but for php, the case is different. You need to have a server installed.
Moving on to your question How to change html to php!!, it's simple, just change the extension of the file.
To run the file, use local server. There are many options you can choose from. Personally I find Xampp easy to setup for beginner. It's my personal opinion though.
To sum up, to change html from php, install a localhost or local server to your computer, migrate your files to server's run directory. You can find plenty of tutorials on setting up localhost.
If you want to run a PHP file after changing its extension. You need to install xammp or lamp server. In the localhost server, you can view your PHP pages on any browser.

How can I get PHP to work on Cpanel when using godaddy after I have purchased the host and domain [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I purchased a host and domain from godaddy and I'm using Cpanel on godaddy for my website. On cpanel, I have added all of my html files with javascript and css on them, and separate javascript and css files as well. However, whenever I add php code, the php does not run. I tried testing simple code such as
<?php
echo "My first PHP script!";
?>
to check, however, "My first PHP script!" does not display on my webpage. Everything else on the webpage using html, javascript, and css works perfectly. Therefore, I am wondering if there is anything else I need to include on the page such any php source code, or is there anything I need to download first before running the code?
As I mentioned in the above comment, make sure that your php code is saved in a .php file and not in a .html file. Also, add your PHP code into the /public_html folder on your server. PHP comes by default with all GoDaddy packages. You don't need to include or install anything.
If it still does not work contact customer service. I found them very helpful whenever I had trouble with my hosting account.

Can PHP pages be run locally? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
Can PHP pages be run locally?
I am trying several demos on creating a contact form, at the moment I am trying this one:
http://www.html-form-guide.com/contact-form/php-email-contact-form.html
I have downloaded the source files and put my own email address in, but when I click submit I get directed to the PHP page. The form's action attribute is set to that PHP page, so I was wondering if it is because PHP is not able to run locally? If I want the form to submit and send to my email would I need to put the downloaded source pages online to make them work?
This is not the only tutorial I've used where this happens.
Sorry if this is a silly question - newbie web developer :).
Thanks.
PHP, in this context, is a server side language. It must be run by a webserver.
The webserver can be installed and run locally.
PHP needs to be executed server-side, which means you will need to set up a local webserver.
The best way to go would be taking a look at WAMP or MAMP or LAMP, depending on your operating system.
You need to be running a PHP server locally, and have the file "hosted" by the server (in the same folder, but usually /var/www/). There are a verity of free programs for this. I like WAMP ( http://sourceforge.net/projects/wampserver/)
You should simple install WAMP server. If you use Windows I recommend this one: http://www.easyphp.org/
When you install it you should copy php file to projects directory and then you can run in your browser http://localhost/projects/ to see your file and to execute it

Upgrading PHP to latest version [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I've been using PHP-5.4.3 for about a month now, and today, I decided to make a switch to PHP-5.5.5, I downloaded the source code, and placed it in C:/php (also renaming the folder php-5.5.5 to php) and I added server variables, as usual C:/php/ <-- but here I got stuck. Because, usually I appended the php.exe at the end, which was found inside the PHP folder so, I could be able to access PHP from the command line, or start the built-in server, but now,I can't find this file, and I can't find a way to start the server from the command line either.
You can compile php yourself. It's simply 2-4 commands and its also explained. I can run configure then make install. You can run configure --help to see all the options. It can be useful if you compile for fast-cgi or need more space or a faster php.
The source code you downloaded needs to be built...
You can download a binary version from here (assuming you're using Windows, of course).
Or read this if you want to build it yourself. There are many other tutorials online.

PHP getting the PHP file [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 12 years ago.
Improve this question
Is there any way to get the source file of PHP like you would for HTML file or javascript from web browser alone? If so how? If not why?
No, this is not possible. Server-side languages are meant to be interpreted and run before the output is sent to the browser.
Of course. But only if the web server is configured to return just the file and not interpret it first. Most web servers hosting PHP files aren't configured this way.
In order to read PHP source code on a remote server, the user needs to find and exploit a remote file disclosure vulnerability. These most often occur in the application its self and can be detected by using a web application vulnerability scanner like w3af.
MySQL based sql injection can be used to read files using the load_file() function as described here.
It is possilbe that the httpd can be vulnerable to a source code disclosure attack, such as this one in IIS.
Only if the web server happens to fail. Otherwise no, because all code is executed on server and only it's result are being send to browser.
There is a way to do this - but you have the web server needs to be setup to serve ".phps" as text/plain as I've done to demonstrate code examples from my web server. However, if you're trying to poach code from a website running php it's really not possible. Not from the web browser.
No, it would pose a massive security risk with MySQL passwords and other sensitive data.
<?printf($f='<?printf($f=%c%s%c,39,$f,39);?>',39,$f,39);?>
so, yes.

Categories