Link to home
Start Free TrialLog in
Avatar of Silent_Killer
Silent_KillerFlag for United Kingdom of Great Britain and Northern Ireland

asked on

"Page not found" error, but the page exists!

We have a website that was working perfectly fine yesterday, but for some reason one of the pages are returning a "page not found" error today. The php page does exist and I've not made any coding changes. I've contacted the webhost and they contend that no changes were made to the linux server. So i'm stumped, what reasons could there be for a 404 error when nothing seemingly has changed?

As a bit of background, our site is used for collecting and reporting KPIs. On one page users enter comments that will later be included in a generated PDF document.  This page's "Save" button calls a processing page ("save_individual_kpis_comments.php") to enter the comments into a database. It is at this point where the processing page is suddenly throwing a "page not found" error. As I've already said, nothing has changed on the coding side and I can see that this function was used yesterday to enter records into the relevant table. Funnily when I retry or type the URL into the browser  it does seem to run the PHP code and attempts to close the page after processing, however nothing is actually entered into the database.

I'm not the programmer who setup this website and my php knowledge is limited so trouble shooting has been difficult. Could anyone point me in the right direction here?
Avatar of stu215
stu215
Flag of United States of America image

A couple of things to try:
-Try re-uploading the file to your server and specify "ascii" as the file transfer type.
-Check the permissions and the owner of the file on your linux server.

-Check to make sure the submission form is sending to the correct file.
( NOTE: some linux systems are case sensitive so the file name & path referred to by the submission form should match the exact relative the path to the destination )
Avatar of Duboux
Duboux

If you don't know much abt it, maybe just duplicate a working php file in the same folder.
And edit its contents by pasting the contents from the file that looks like is missing.
Then rename the not-working-file to something unique.
And rename the duplicated file you pasted the code in to the correct name.

This way you won't have to upload anything or play with permissions or transfer types ;)
If neither of the above posts led to a solution, it would be helpful to know the O/S - Linux, Unix, Windows, something else?

Having said all that, my first suspect is a permissions problem as Stu pointed out.  Specifically, be sure that the file can be read by the web server software.  Compare the permissions of the PHP file in question with other PHP files in the same folder.  

If it's Linux or Unix, I would make sure that you haven't lost a symbolic link.  I don't know if your programmer used symbolic links, but I do.   (This is why I want to know the O/S.  There's little point in me offering Linux/Unix ideas if the server is Windows).

Another place I'd look, which I'll grant will be difficult for you, is the code itself.  It's possible (I don't think likely) but possible that the page is attempting to load a different page (than the page you expect) and the second page is the page that actually is missing or has incorrect permissions.

Avatar of Silent_Killer

ASKER

To hmccurdy: It's Linux, symbolic links sound interesting and they may have been used, if you can give me an example of one, maybe?

We're using a webhosting company called WebHosting UK and have a shared Linux box with them. My thought is that it must be something on the server environment that has changed (upgrade of PHP version, some server variable change, ??) that is causing the problem and maybe we just need to rerun some "indexing" service to remap the site. I'm hesitant to start messing with the code 1stly because I'm not a proficient PHP programmer and secondly because the code was working fine on Tuesday and then this error yesterday without me having touched a thing on that site.

The webhost maintains nothing has changed. Now before I get into a (heated) debate with them about this, do you guys agree that it must be a server issue and not a coding one?

Thanks for all the posts by the way I'm definately going to check out the permissions suggestions, although again, I don't know who would have messed with it in the first place.

Many thanks for the help!
Without knowing what all the software does, I can't be sure.  I think it's more likely that something happened on the computer.  However, I question if the web host has the capability to solve the problem even if it is their fault.

One thing to do, if you have shell access to the computer, is see when it was last booted.  The w command will give up the up time.  

$ w
08:19:16 up 2 days, 21:03,  6 users,  load average: 0.20, 0.24, 0.18

If it was rebooted between working and not working, then I think it's very likely it's a server problem.

Best I can do without seeing the code and that amount of work is likely beyond the role of EE.  (I suppose Ray could disagree but I'll let him do that if he does.)
It sounds to me that you don't have ssh access and just have a hosting account.
If this is the case the only thing you quickly can do yourself is either upload the broken file again or what I suggeted earlier using either a ftp program or a web control panel.

if you do however have ssh access, u could run the following commands:
(assuming the code in your broken file is still correct)
assuming broken filename = broken.php
assuming a working filename = index.php
assuming you managed to cd into your folder

mv broken.php broken.old.php
cp index.php broken.php
cat broken.old.php > broken.php

It just creates a new broken.php file with the correct contents, and the same permissions as a working file.

I wouldn't waste energy on yelling at your host abt this. It could be anything, from bad disk sector to something else.
Just fix it yourself and have a smile back on ur face asap ;)
Side comment related to Duboux's comment.  Years ago, we had the company website on a shared computer.  In this case, I did have ssh access and they included a regular Linux development env.  I could write CGI's in C.  (Years ago, I said.)  At one point, the compiler libraries became corrupted.  Clearly, without root access, nothing I could have done.  The ISP had no idea the library files were corrupted or how it happened.  But they were.  

They didn't know how to fix it and by then I stopped caring because we just happened to be migrating to a new server (that we controlled).  

Just saying lots of things can happen and the ISP doesn't necessarily have any idea it happened or why it happened or how to fix it.
Do you have a copy of phpinfo() output from the old days when everything was working?  You might want to compare that to phpinfo() today.  Look for things like magic quotes and register globals.  The default settings for these may have been changed.
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_6630-Magic-Quotes-a-bad-idea-from-day-one.html
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_7317-Register-Globals-a-bad-idea-from-day-one.html

You might also want to look at the build date for the PHP installation to see if it is very recent.  Just a thought... ~Ray
Why don't you fire up a html index page just to prove you're still talking with the server.
Hi guys,

I've tried all your suggestions and created a new page from one that was working and just containing the phpinfo() statement to see if it can at least run that, however it still comes up with the "file not found" error. When I manually enter the URL the PHP info is displayed (unfortunately I don't have an older output to compare it againsts), so the problem is not with the content of the file. I've also checked the permissions and they are the same as all other executing scripts.

Could the problem be in the POST method from the calling page?
//<form method="post" action="save_report_comments.php" target="_blank">

This seems impossible to troubleshoot seeing as I can't even get it to go to a new page to display the values that are being posted.

Thanks for all the help and suggestions so far. If I can't get it fixed this week, I'll hire a freelance programmer and let you know the outcome.
While I'm confident that I could solve this, I nominate Ray (not that you are taking nominations) as the freelance programmer.
has the php software on your server been updated ?

anyway, that <form> line you posted wants to open the save_report_comments.php file which must be in the same directory.

maybe you can test a little, by changing the action to another page.
perhaps to a new page, that only has the following code: <?php echo "hi"; ?>
Then test by sumbitting that form, and see if u see the word "hi" on a blank page..
If so, then either:
- your save_report_comments.php file doesn't exist in the same folder
- your save_report_comments.php has no read-access for everyone
- your save_report_comments.php has a different ownership (maybe root or apache or w/e)
- there's a .htaccess file messing up your save_report_comments.php from showing
Have you checked .htaccess file. Is there any redirection set?
ASKER CERTIFIED SOLUTION
Avatar of Silent_Killer
Silent_Killer
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Solution provided by external consultant.