Problems with very first php script - "Object not found"

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Problems with very first php script - "Object not found"

Postby andyd01 » 31. January 2009 03:41

You can create a file with the Microsoft NotePad/WordPad editors and give it a name like "test.php" and put this file in the htdocs directory and when you set your browser to http://localhost/test.php, you will get an error page that says Object not found.

This is happening because the file created by NotePad/WordPad is a "text file", not a "php file". Look at the files in the windows explorer, view, detail and you will see the file type names in one of the columns in the middle.

It took quite awhile for me to figure out this was what was happening, hopefully this information saves others some time. It would also be nice to recommend some editors to use for creating the php files that would not have this problem as part of the xampp installation, or xampp getting started directions.

I used the SciTE editor, which is can be found w/google and downloaded at no charge. This editor has a mode you can set to support php,
others probably do as well.

I created a script with this editor with php filename extension, and save as php or read as php or show as php, saved it in the htdocs directory, and now everything works.
andyd01
 
Posts: 1
Joined: 31. January 2009 03:03

Re: Problems with very first php script - "Object not found"

Postby Izzy » 31. January 2009 03:56

andyd01 wrote:You can create a file with the Microsoft NotePad/WordPad editors and give it a name like "test.php" and put this file in the htdocs directory and when you set your browser to http://localhost/test.php, you will get an error page that says Object not found.
The correct and only detailed error message may be found in the Apache error.log file, browser errors are only canned messages with no individual error detail provided and so are only a preliminary warning that something is not quite right.

andyd01 wrote:This is happening because the file created by NotePad/WordPad is a "text file", not a "php file". Look at the files in the windows explorer, view, detail and you will see the file type names in one of the columns in the middle.
Incorrect because a php file is a text file and the indicated column is not indicative of the format or content of a file only it's actual file extension associated with that file - for example if you change the test.php into test.txt then it will show as a text file which of course it is.

Using a text editor is mentioned in several locations on the XAMPP home pages as well as in the FAQ.


Only use a pure text editor like Notepad, not an RTF or Word editor like WordPad, or like you did use a dedicated script editor and there are many that fit that bill, to edit and read php files which are indeed only pure text files - an RTF or Word editor are not text file editors and they include all sorts of unknown invisible formatting characters as well as some visible character differences to a text editor into a file which Apache does not recognize and so throws out the code when parsing, with an error message.

I use and have used NotePad Pro, a notepad pure text and code editor replacement, for years to edit all manner of scripts including but not limited to php with absolutely no issues at all.

BTW Notepad should not be quoted in the same context as WordPad as they are two different types of editor, you can use Notepad to edit all editable files in XAMPP but not WordPad in it's default file save state of RTF, which is what you appear to have done, instead of changing the default Save as RTF to Save as Text Document for your test.php file.

So before posting in these forums please check your facts first.

For the record:
Notepad Overview wrote:Notepad overview

Notepad is a basic text editor that you can use to create simple documents. The most common use for Notepad is to view or edit text (.txt) files, but many users find Notepad a simple tool for creating Web pages.

Because Notepad supports only very basic formatting, you cannot accidentally save special formatting in documents that need to remain pure text. This is especially useful when creating HTML documents for a Web page because special characters or other formatting may not appear in your published Web page or may even cause errors.

You can save your Notepad files as Unicode, ANSI, UTF-8, or big-endian Unicode. These formats provide you greater flexibility when working with documents that use different character sets.
WordPad overview wrote:WordPad overview

With WordPad, you can create and edit simple text documents or documents with complex formatting and graphics. You can link or embed information from other documents into a WordPad document.

You can save your WordPad file as a text file, rich text file, text file for MS-DOS, or Unicode. These formats provide greater flexibility when working with other programs. Documents that use multiple languages should be saved as rich text files.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: Problems with very first php script - "Object not found"

Postby nlsdg » 30. May 2009 05:26

This is not a PHP problem, but a windows problem. Turn off the 'hide extensions for known filetypes' in Windows Explorer:
Tools, Folder options, View, and clear the checkbox.
If this option is active and you try to save a file from notepad as test.php it is really saved as text.php.txt. (and that's why you see 'Text file' in the file-type column.)
And because the extension is hidden you can't rename it. Change test.php to test really makes it test.txt, so still a text-file.

The feature is designed to prevent users from accidentally changing the extension, because the extension determines the application used to open the file when double clicked on. But is also a source of problems.
Misused by malware to trick users into opening a executable, when they think they are opening a picture, of something else, by giving the file a double extension.
file.jpg.exe is shown as file.jpg. Use thinks 'jpg, that means picture, so it's safe. He opens it, and bingo, another machine infected...
nlsdg
 
Posts: 1
Joined: 30. May 2009 04:58

Re: Problems with very first php script - "Object not found"

Postby OneTowers » 18. November 2013 08:40

You have been the only one who answered my question. I spent hours trying to see if PHP was activated in my computer and could not get the simple php file to work. But the focus you made on the "htdocs" which is the main folder for "xampp" made the difference. Now all the files work and I can continue with my training. Thanks again for the reminder. Sometimes we get so focus on the wrong thing and need to close everything and start again.

Glad I found your response

Sincerely,

Juan Torres
OneTowers
 
Posts: 1
Joined: 18. November 2013 08:35
Operating System: Win 7 Pro


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 251 guests