billjup Posted April 18, 2012 Report Posted April 18, 2012 I'm a newbie so please bear with me. I'm learning how to hand code HTML, CSS, PHP, etc... When creating my files I name them with the appropriate file extension .htm, .css, .php, etc... I've used Notepad and Word to create files. When I try to see the result of my code in a web browser (IE9) it displays the code, not the results of the code. Look at the attachment. Very simple straight-forward PHP. I named the file with .php and it still shows that is is a .txt file. What am I missing? Thanks! Quote
Wickham Posted April 18, 2012 Report Posted April 18, 2012 If you want to see a .html or .htm file displayed in a browser, double click the filename in your file list like Windows Explorer and it should open your default browser, or right-click and "open with" another browser. You cannot see a .php file displayed properly in a browser from a local file unless you have WampServer2 or XAMPP installed as these have Apache server to process the PHP, so check these online or install one of the programs. CSS files when double-clicked should open in Notepad if css files are set to open in Notepad or you can right-click choose program. Don't use Word for coding as some characters like " and ' can carry unwanted hidden code which affects the display. Quote
falkencreative Posted April 18, 2012 Report Posted April 18, 2012 I think the issue is that your operating system is hiding the actual file extension, and you are actually creating files that are named like this: test.php.txt. See this topic for more info/how to fix this: http://www.killersites.com/community/index.php?/topic/3010-cant-open-my-website/page__gopid__16509entry16509 Quote
Wickham Posted April 19, 2012 Report Posted April 19, 2012 Ben's probably right, your files probably have .txt added on the end of the filename that shouldn't be there. When you have been coding in Notepad (or probably most other text editors) and you want to save the file for the first time, use Save As (instead of Save) and type your filename like index.html or contact.php and then make sure Save As Type is All Files (*.*) and not Text Documents (*.txt). Then check that Encoding is ANSI not UTF-8. After the first save, you should be able to click Save instead of Save As after future edits. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.