.php pages not working on xampp - php

I'm running xampp version 2.5 on windows 7 and ftp'd over a website I'm working on (www.dfwcertautos.com). None of the .php pages load, however the .html pages load fine. I created a test.php page with "hello world" and it loaded correctly. Any suggestions for getting it to run properly? The site has no database, however it does have an XML feed coming in to it from another service. I didn't make any changes to the htaccess file.

What FTP client did You use?
It is possible that when copying the files in "Text" and not "Binary" mode there was a special whitespace added on the beginning of each PHP file so the PHP file cannot be executed on APACHE server...
EDIT: another idea - aren't You using PHP short tags <? instead of <?php on Your localhost while on the server the short opening tag (<?) is not permitted...?

Related

PHP file isn't outputing to local browser, just showing code

Originally, I would select my php files and it would open the site on my local browser, I accidently opened it to notepad and now it will only open the code to editors. Does anyone know how to change the file setting back to when it would execute in the local browser? Ive tried resetting the filetype associations and resetting the file extension settings in the registry editor. I am currently using Windows 11
If you are not using a servlet like wamp or xampp you cannot process the php file on localhost.As long as the files have a php extension and are in the target folder of the servlet, while the servlet is active (example: if there is an index.php in the www folder in wamp. It will work if you type localhost/index.php in the browser.) your php files will work.

If I rename an index.html to index.php, the CSS style disappears

Yesterday I discovered a website called Too Plate:
https://www.tooplate.com/about
It has free HTML templates, and all they are very beautiful.
I had the idea to turn the theme that I chose to PHP, so, I just renamed the file index.html to: index.php
But, when I open it using a brwser, all the style is gone... As if the template could not find the CSS file... But I just renamed the file, I did'nt change anything inside the code (I only added the "" tags a the beginning...)
This is the template:
https://www.tooplate.com/view/2122-nano-folio
How can I fix this, please?
Once you add the PHP extension it handles the file as a PHP script, which is a server-side language that's get executed on the server before loading the page, so to view ant PHP file you have to have a server running the PHP code, but HTML runs on any browser.
So what happened was that because you changed the extension the browser treated it as a PHP script and cant Execute the script because it's not a server.
you must need to run the code in server eg: local servr xampp or wampp then only your php code work try this
https://felbdogg.com/test2/index.php
code works fine... I'm not sure what you changed but I uploaded it to my server and works the same as what I downloaded.
If your opening it on your computer without a server it will not load. XAMPP is free and works great for testing.

PHP echo: can't reproduce W3school's code [duplicate]

This question already has answers here:
PHP code is not being executed, but the code shows in the browser source code
(35 answers)
Closed 6 years ago.
I just started learning php and this is what I have done:
I copied the code from the left panel on this page and pasted them into a local html file. But when I open the html in browsers (firefox and chrome), the page doesn't look like what it should be: There is no format and the word 'echo' and some symbols are shown on the page. Why does this happen? How can I fix this issue?
PHP is a serverside scripting language. It has to be interpreted by a PHP interpreter that is in some way connected or integrated into an HTTP (web) server. There are a number of different ways to do that, with varying degrees of complexity.
How and where you setup your php + webserver is up to you, and the ways to do that typically start with the operating system you are running your workstation on, assuming you want to do so, locally.
You can go right to here for a jumpstart: http://www.phptherightway.com/#getting_started
The extension for a page that has php codes must be .php and not .html. Also, for the PHP code to execute you must be running Apache server on your machine.
This is a good tutorial for beginners, which tells you how to run PHP codes.
The steps are as follows
Open any Text Editor. Install new if you don't already have any good Text Editor installed. (My Favorite is Sublime Text & Notepad++)
Write the following PHP Program / CODE in the Text Editor: '; ?> This is
test.php File.
Save the file in XAMPP Installation Directory \ Web Root Directory Note-1: Default XAMPP Installation Directory in Windows is C:\xampp
Note-2: Default Web Root Directory in XAMPP is htdocs. All your php
files will have to be in this htdocs folder. That means, for a typical
installation of XAMPP in Windows, you will have to save the PHP CODE
in C:\xampp\htdocs folder.
When you save the file, name it test.php (just as an example, any valid file name with .php in the end will work). Note: when you save
this file, make sure it has no .txt extension at the end. Some text
editors place .txt at the end of file name, so it becomes test.php.txt
instead of test.php. To avoid this, when you save the file using any
text editor, place double quote around the file name: e.g. "test.php"
Then, go to XAMPP installation folder (typically, C:\xampp) and run xampp-control.exe by double clicking it.
In the xampp-control window, click the start button beside Apache. Later, if you need other options like MySQL, you'll also have to start
MySQL by clicking the start button beside MySQL in the XAMPP control
Panel. Note: if your OS hides common file extensions, then you'll see
xampp-control, instead of xampp-control.exe
Now, in your web browser's address bar, type the address: http://localhost/test.php

php not loaded but the code exist in view source page

i was setup my server, unfortunately the php page not loaded in the browser. Looking at the view source pages, i see my php codes. I using centos and install cpanel.
What usually reason for the problem?
It means PHP is not running.
Have you tried reaching localhost in your browser? Generally you should see the PHP index file, which tells you if the server works or not.
A few possibilities :
Is your file in the proper root folder? Is is accessed via localhost (not file system!)
is your file in .php (ex. NOT .html)?
Are you using full <?php ?> tags? Some server configs won't recognise <? ?>

Call to PHP prints source, doesn't run when called from another file

I have a quick question that I can't figure out. I've tried searching Google and following examples, but I can't find anything.
I have an HTML form that I'm trying to process with a PHP file, but when I submit the form, it merely prints the source of the PHP file, it doesn't execute it. If I run the PHP file by itself (not indirectly through the HTML button), it works fine.
HTML form header:
<form id="registrationform" name="registrationform" method="post" action="processregistration.php">
Submit button:
<button type="submit" value="Submit" >Create</button>
The PHP form is just <?php print "Hello"; /?
Again, it runs fine if I just run the PHP file, but prints the PHP file (doesn't run) when it gets called through the HTML form.
Any help is appreciated.
edit-Running locally through Coda
edit-Here is the output that I'm getting:
Output when the PHP is called through an HTML action:
</php
print "Hello";
?>
Output when I run the PHP directly through Coda:
Hello
I had the same problem and just fixed it on my coda version 1.7.4
I installed MAMP on my mac and set up the apache path under MAMP preferences to the folder where my sites are located;
/Users/yourUserName/Sites
this points MAMP's 'http://localhost:8888' address to your sites folder, if you paste that on your browser you'll now see your sites folder's content in the browser.
then, all you do is point the local site's connection settings to the site you are testing;
I was going to post an image, but I'm new to the site and wasn't allowed.
Under my site's preferences i set up the addresses as follows;
Root URL : 'http://localhost:8888/yourSiteRootFolder/'
Local URL : 'http://localhost:8888/yourSiteRootFolder/'
Remote Root : /yourSiteRootFolder/
Local Root : /Users/amartinez/Sites/yourSiteRootFolder/
I hope this is related to the problem you're having and helps you fix it.
Line #19 from Coda 1.6 Release notes:
Coda no longer tries to locally
preview a remote PHP file while
editing/previewing
Listed under "Improvement" - doubt they brought it back for the 1.7 release.
I'm running Apache2/PHP5 10.5.8 OS X (no problem reproducing your issue with Coda)
Even when running my form.html and post.php files from /Library/WebServer/Documents folder.
My sample files work fine in the Apache env....I just needed to run them through Coda to "break" them. :-)
Are you sure the html file and the php script are on a server with php support enabled?
I've never used Coda, but you need to be running it through a server (e.g. Apache + PHP). You cannot just open the file itself within Windows.
Try looking at xampp as a quick server for testing.
If it works properly, you should be viewing the PHP file on something like http://localhost/test.php instead of file:///something/test.php.
This may be because you don't have PHP installed on your server. I would check to make sure that your hosting package included PHP, pre installed.
Here are some resources to get you started with that, if not installed:
http://www.thesitewizard.com/php/install-php-5-apache-windows.shtml
http://www.php.net/manual/en/install.php
http://www.w3schools.com/PHP/php_install.asp
Edit: actually, I think I may have found it.
If you look at the starting PHP tag, you have a slash instead of a ?. If that's in your script, just change that to <?php. But it may not be, it could be that's just question format-ing.

Categories