Issues with PHP page output

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

Issues with PHP page output

Postby slak74 » 17. June 2010 08:46

Hi,

Installed XAMPP and the code below works when placed in C:\xampp\htdocs folder and accesssing via http://localhost/a.php

<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php
echo "Hello World";
/* echo("Hello World"); works as well, although echo isn't a
function (it's a language construct). In some cases, such
as when multiple parameters are passed to echo, parameters
cannot be enclosed in parentheses */
?>
</body>
</html>

However, other files that i do have of PHP do not seem to work. Can someone help resolve this issue. The error i get is as below:

Object not found!

The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

If you think this is a server error, please contact the webmaster.
Error 404
127.0.0.1
6/17/2010 1:14:33 PM
Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1

The code is as below:

<?php
// We'll be outputting a PDF
header('Content-type: application/pdf');

// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="Franchisee_Application_Form.pdf"');

// The PDF source is in original.pdf
readfile('download/Franchisee_Application_Form.pdf');
?>

Trying to access the page as follows:

https://127.0.0.1/down.php or https://localhost/down.php

Gives the same error of object not found. Kindly help.

Thank you for the help and time.

Regards,
Lakshmi
slak74
 
Posts: 7
Joined: 17. June 2010 08:34

Re: Issues with PHP page output

Postby Radzio » 17. June 2010 10:48

It can't find the down.php file at all?
Radzio
 
Posts: 81
Joined: 05. June 2010 12:26

Re: Issues with PHP page output

Postby slak74 » 18. June 2010 06:26

Hi,

That what it seems like. The page does exist with the code posted in the folder C:\xampp\htdocs.

Please help find me a solution. Thank you.

Regards,
Lakshmi
slak74
 
Posts: 7
Joined: 17. June 2010 08:34

Re: Issues with PHP page output

Postby Nobbie » 18. June 2010 10:33

Which editor did you use to create down.php?

If you use Notepad, there might be a file down.php.txt instead of down.php (extension *.txt is not shown in your explorer per default). Check that!
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: Issues with PHP page output

Postby JonB » 18. June 2010 10:44

why don't you post the actual error - that might help

just copy & paste the whole thing

is it a 404 error or something else?

:)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Issues with PHP page output

Postby slak74 » 18. June 2010 12:06

Hi,

It is a .php extension only :( . That is correct.

The error has already been pasted in the first post, but pasting again

Object not found!

The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

If you think this is a server error, please contact the webmaster.
Error 404
127.0.0.1
6/17/2010 1:14:33 PM
Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1

Do let me know. Thank you for your time.

Regards,
Lakshmi
slak74
 
Posts: 7
Joined: 17. June 2010 08:34

Re: Issues with PHP page output

Postby Radzio » 18. June 2010 12:11

Have you tried renaming your file? Have you tried echoing something simple in this file?
Radzio
 
Posts: 81
Joined: 05. June 2010 12:26

Re: Issues with PHP page output

Postby slak74 » 18. June 2010 12:21

Hi,

Tried copying the code and pasting it into another file with the extension .php and viewing it, no luck.....gives the same error...

I guess I am missing something here. Request the PHP gurus to see the code of the file posted.

Regards,
Lakshmi
slak74
 
Posts: 7
Joined: 17. June 2010 08:34

Re: Issues with PHP page output

Postby Radzio » 18. June 2010 12:42

The code is OK.
Are you sure you put it in the right dir and you're trying to access it properly?
Radzio
 
Posts: 81
Joined: 05. June 2010 12:26

Re: Issues with PHP page output

Postby slak74 » 18. June 2010 12:49

Hi,

The file is in the folder C:\xampp\htdocs

This is where the file a.php is there, which has hello world code, which works well.

I am accessing using the following URL:

http://localhost/down.php.

Thank you.

Regards,
Lakshmi
slak74
 
Posts: 7
Joined: 17. June 2010 08:34

Re: Issues with PHP page output

Postby Radzio » 18. June 2010 13:43

That makes no sense. PHP code is ok. If you can access a.php then try copying this code there.
Radzio
 
Posts: 81
Joined: 05. June 2010 12:26

Re: Issues with PHP page output

Postby slak74 » 18. June 2010 14:49

Hi,

Actually copy pasted the code of down.php into a.php and accessed the page using http://localhost/a.php, code as below. What gets displayed is only the string "hello world". Please help, thank you.

<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php
echo "Hello World";
/* echo("Hello World"); works as well, although echo isn't a
function (it's a language construct). In some cases, such
as when multiple parameters are passed to echo, parameters
cannot be enclosed in parentheses */

// We'll be outputting a PDF
header('Content-type: application/pdf');

// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="Franchisee_Application_Form.pdf"');

// The PDF source is in original.pdf
readfile('download/Franchisee_Application_Form.pdf');

?>
</body>
</html>

Regards,
Lakshmi
slak74
 
Posts: 7
Joined: 17. June 2010 08:34

Re: Issues with PHP page output

Postby Radzio » 18. June 2010 15:06

Because you cannot modify header after sending data. File should consist only of PHP block and shouldn't echo anything.
Radzio
 
Posts: 81
Joined: 05. June 2010 12:26

Re: Issues with PHP page output

Postby slak74 » 18. June 2010 15:31

Hi,

Thank you so much for your help. I had moved my XAMPP folder and had run that setup_xampp.bat file. But the move does not seem to have taken any effect. When i replaced the files back in the original folder, it works. Thank you so much for all your help and time. Regret that i caused confusion.

Can you please help me know which would be the best place to learn php, I am a beginner Thank you so much.

Regards,
Lakshmi
slak74
 
Posts: 7
Joined: 17. June 2010 08:34

Re: Issues with PHP page output

Postby Radzio » 18. June 2010 15:54

php.net :D
Practice will make you a champion ;p
Radzio
 
Posts: 81
Joined: 05. June 2010 12:26


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 120 guests