The server responded with a status of 404


I got this error in my PHP file this morning and I am unable to apply any style to page and anything I add in my HTML file will not show up on the web page.
Does anyone know what this error means?

As it says there, a “404” error means that the file you are trying to access is not found. On the right it tells you which line of which source file is throwing the error, I believe, though I’m not certain on that.

Here’s a list of those HTTP codes and their meanings: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes

1 Like

Hi @ubulade78 and a warm welcome to the forum.

The error states that files cannot be found which is probably due to incorrect relative paths from the current file.

What I usually do is to find the exact path the current file is located and then examine the relative path of the file which is giving the not 404 error.

<?php 

echo '<p>Path of current file: ' .getdir() .'</p>';

Edit:
It is usually a lot easier if you show the contents of the problem file and users can try the file on their own computers. Also if it is possible to show an online web-page.

Hi John, there is no getdir() function in Php so that must be a custom function. For clarification, to get the full path of a file you just need this…

echo dirname(__FILE__);

1 Like

Whoops - I meant echo getcwd(); // get current working directory

Alternatives:


echo getcwd(); 
echo '<br>';

echo __dir__;
echo '<br>';

echo dirname(__FILE__);
echo '<br>';

1 Like

OMG Thank you so much guys, i finally figured it out. I had three diffrent CSS file that were not in the folder linked to the html. It was right right there and i didn’t even notice.

2 Likes

OMG Thank you so much, i finally figured it out. I had three diffrent CSS file that were not in the folder linked to the html. It was right right there and i didn’t even notice.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.