Pages: Previous12
Current Page: 2 of 2
Re: Wamp shows PHP code in browser ( not processing php script )
Posted by: RiggsFolly (Moderator)
Date: June 05, 2016 02:57AM

Hi,

please start a new thread and answer these questions [forum.wampserver.com]

before be a lot more specific about it is not working

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Wamp shows PHP code in browser ( not processing php script )
Posted by: SimonT (---.lightspeed.stlsmo.sbcglobal.net)
Date: June 15, 2016 12:09AM

You said:

"No, the filename already is php.
I'm sure because Windows asked me if i'm sure i wanted to change"

When is Windows asking you about changing the extention?

Tip - This works on Windows 7 and below, I haven't used 8 or 10 except to play with it when I was looking at new computers at various stores.

Go to Control Panel (one way is to click Start -> Setings -> Control Panel

Double click "Folder Options" on the Control Panel

This should pull up a Folders Option window with three tabs across the top.

Click on the View tab

Look down the list, it is close to the top, for "Hide extensions of known file types" - UNCHECK IT IF IT IS CHECKED!!

I strongly recommend you uncheck this on all of your computers and advise friends, family, co-workers, company IT people - anyone who used Windows to uncheck it.

It has been around since Windows 95 and is the way a huge number of virus were spread - and still being spread.

What the setting means, if checked, is if you are looking at the name of a file, Windows may be not showing you the true extension and you can mistake it as a safe file to open when it is actually a very unsafe file to open.

For instance, in an email you might get an attachment file, and the filename might look like

greatphotofromparty.jpg

If you uncheck the setting, it would look like this:

greatphotofromparty.jpg.exe

"Open" that file and you will be running a program and welcoming the scum into your computer.

Always uncheck "Hide extensions for known file types" -- ALWAYS.

Back to your original question:

@gogaz said:

"Left click on WAMP icon into Windows' running icons and go to PHP > PHP Settings > Expose PHP"

That was new setting for me, and when I pulled up the setting it was Checked. So - I did a Google on PHP Settings Expose PHP

Here's two page which address that setting:

[php.net]

and

[stackoverflow.com]

As you will find, that has nothing to do with you seeing the PHP code instead of the results of the sever executing said code.

The only reason I know why the server sends PHP as text which the browser displays is when the PHP code is in a file whose extension is not .php

There may be others, but that's one I've encountered.

Someone spoke of using NotePad to edit the PHP code - poor choice. It is intended a a Note Pad for text, not programming code.

You want an editor which at least understands that every file you save is not supposed to have the .txt extension unless you take specific steps to say otherwise.

I use Expression Web and ConText editor.

EW is a web site IDE (Integrated Development Environment) which allows you to do WYSIWYG designing of pages also has a Code mode in which you can work directly with the code - be it HTML, CSS, JavaScript, PHP, etc.

I find I spend most of my time in Code mode :-)

EW is MS product which replaced MS Front Page. EW has been integrated into MS Visual Studio and EW 4 has been made free - with no support of course. IF you've never used anything like it, it can have a steep learning curve - meaning that it might be a while before you begin to produce good results with little effort.

You can download it at [www.microsoft.com]

There is an independent forum at [www.expression-web-designer-help.com]

ConText editor is a programming editor which supports PHP, JavaScript, HTML, and other "languages."

It does not have as steep a learning curve but the program does have options in places you don't expect them.

Such as the "Recent Files" entry in the File menu - instead of being close to the top, as is the case with most other Windows programs, it is toward the bottom of the menu.

But once you get used to his "take on things" I consider it a very good editor for even a beginning.

You can get it at: [www.contexteditor.org]

If you decide to go with Context Editor, send me a private message and I'll send you, via email, some coding you put in ConText to activate function keys to do such things as syntax check (called Linting in the UNIX/PC world) your PHP and JavaScript code before you try to running it - it save a lot of time.

I have also some batch files which you can hook to function buttons to make backups as your work on the file.

The thing about a proper editor for code is that you tell it once, either when you open a new file or when you save it for the first time, what type of file it is - if you tell PHP, it will never change the extenstion unless you specificly tell it.

Chose and install a real programming editor and stop using editors designed for just text.

A programming editor will amaze you - the good ones will highlight the syntax and even suggest endings for what you are typing.

For instance, in a good editgor, you might be typing: document.getE

and when you get far enough into the statement for the editor to recognized it, it will suggest the ending which makes it: document.getElementById( and you press enter to accept it and then continue typing the rest of the statement as it needs to be.

Try one - you'll like it.

Now, go use Windows Explorer, not Internet Explorer they are two different things and check that the web page files all have the correct extension.

Also - how are you trying to open the web page: via WAMP localhost, a virutal host, or with the browser's Open File in the File menu?

You were told you put the PHP code in the www folder - ah, that's just partially correct.

WAMP will create a directory (I know the hip word is folder but they have been directories to me for 43+ years and I'm not going to change now)

As I was saying, WAMP will create a subdirectory named www. under the wamp or wamp64 (depends on which version of WAMP you are running)

You should create a subdirectory of www for each of your web sites you want to test with WAMP.

Say the one you are working on is a old cars site, you could use oldcars as the subdirectory under the WAMP www directory.

By the way, it can get a bit confusing whether you use the \ or the / in path names - Windows uses \ and most "pc" things use /

I'm showing \ not / because that is what Windows explorer will display.

C:\wamp64\www\oldcards or C:\wamp\www\oldcars

That is the "root" of your web site and where all files and subdirectories of the site should reside.

Do it that way and everyone here will be more able to help you with problems because they will probably be assuming - without asking - that you are doing it that way.

So -

Get a real programming editor and install it and start using it for at least the PHP files.

Put your site files in a sub directory of the \wamp\www or \wamp64\www directory.

Create a virtual host:

Go the WAMP localhost - Click the WAMP icon in the sytem tray (bottom right corner of the screen), then click Localhost - it is as the top of the WAMP menu.

The WAMP local host window should appear. At the bottom left you will see Add a Virtual Host -- click that.

The Add a VirtualHost window will open.

In the "Name of the Virtual Host" box put the name you wish to refer to the site as, in effect, the domain name but use something different than your online domain name to avoid conflicts with DNS enquries and other issues.

In the "Complete absolute path of the VirtualHost" box put the full (as is said on that line) the fully qualified path to your subdirectory you created above. If you created a subdirectory named oldcars under the WAMP www directory on the C: dirve, you would enter c:\wamp\www\oldcars or c:\wamp64\www\oldcars again depending upon what version of WAMP you installed, 32 bit or 64 bit.

Click the very long button, at the bottom on the right of the page, labeled "Start the creation of the viruatal host" and wait a moment and a virtual host should be created and will appear in the WAMP Virtual Host menu

You open your site by clicking the WAMP icon in the system tray, click Virutal Host" and then click the virtual host you want to open - the one you just created - oldcars, in this example.

That is the way you open your web site for testing - Apache, PHP, MySQL, etc. will work just like they should on a remote hosting company server. I don't mean eveeryting will work as you intended it to - there are these pesky things called program bugs which you might find in your HTML, CSS, PHP, JavaScript, etc.

If you write a program incorrectly, it will funcdtion incorrectly - everytime.

You may run into issues where the Apache or PHP or MySQL packages are configured differently than those on the hosting companies server, those are things you have to deal with as you encounter them.

Let me know if you are still having problems with the PHP code displaying rather than being executed.

Oh - I think you said something about this earlier --

You do have your PHP code wrapped in the .php files with <?php and ?> - right?

Well, good-luck (now I have to proofread this reply that has tuned into a novel)

Options: ReplyQuote
Pages: Previous12
Current Page: 2 of 2


Sorry, only registered users may post in this forum.