/    Sign up×
Community /Pin to ProfileBookmark

PHP Script not working

Hello, I have this PHP script and I would just like to know what this line means from the instructions:

[B]Copy and paste this whole script into your page where you would like your error to be displayed.[/B]

Does this mean a HTML page which I have already created or a new blank page and just save it as a PHP ? Currently I have a HTML page which I created and I’ve pasted the script within the <head></head> and it’s not working.

to post a comment
PHP

11 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMar 01.2009 — There's really no way for us to be sure exactly what should be done since we don't know what PHP code you're working with. A couple things that are likely to be true, though, are:
[list]
  • [*]The file you put it in will need to have a ".php" file name suffix.

  • [*]If the intention of the PHP code is to output something to the user, probably the <head>...</head> section of the HTML is not a good place. More likely somewhere within the <body>...</body> would make more sense.
  • [/list]
    Copy linkTweet thisAlerts:
    @WhiteDragonauthorMar 01.2009 — I solved my problem but I don't know why the 404 error code for wordpress shows up instead of a 404 error that I have ?
    Copy linkTweet thisAlerts:
    @RudiMar 02.2009 — I solved my problem but I don't know why the 404 error code for wordpress shows up instead of a 404 error that I have ?[/QUOTE]

    Most likely something to do with a .htaccess file overwriting your custom error page, assuming that's what you mean.
    Copy linkTweet thisAlerts:
    @WhiteDragonauthorMar 02.2009 — You can hook the '404_template' filter and return the path to the template you want it to use or false if you don't want any output.

    ______________________________________________________
    function override_404_template( $template ) {

    return '/var/www/errors/404.php';

    }

    add_filter('override_404_template', '404_template');

    ______________________________________________________

    So where do those lines go in the HTACCESS? This is what I was told to do.
    Copy linkTweet thisAlerts:
    @VictorinoxMar 04.2009 — It may help if you would:

    Describe the problem in full.

    Show more information about the instructions you've been given.

    Provide a working example of a URL that should return your custom 404 error page.

    Provide a working URL to your Wordpress installation.

    Show the current contents of your .htaccess file.
    Copy linkTweet thisAlerts:
    @WhiteDragonauthorMar 04.2009 — I was told the following, but where do I put this in my HTACESS?

    ____________________________________________________________
    You can hook the '404_template' filter and return the path to the template you want it to use or false if you don't want any output.

    function override_404_template( $template ) {

    return '/var/www/errors/404.php';

    }

    add_filter('override_404_template', '404_template');
    Copy linkTweet thisAlerts:
    @VictorinoxMar 05.2009 — Hold your horses!

    You need to paint the whole picture for us.

    Let's take it one step at a time...

    What are you trying to achieve? For example "I'm using Wordpress and want to use a custom 404 error page rather than the default".
    Copy linkTweet thisAlerts:
    @WhiteDragonauthorMar 05.2009 — That is what I mentioned. I created a custom 404 error page and instead the wordpress 404 error page is appearing and I don't want this rather I want my own custom error page to show up that is why I posted the code in Post #7 which I was told and so where does it go in the HTACESS and how do I use that code?
    Copy linkTweet thisAlerts:
    @WhiteDragonauthorMar 06.2009 — Alright, so I have to save error pages as PHP. I have yet to try that link you gave me skywalker. I do have a question, what does the code below do ? And where would it go ? And is it the same thing you have described by that link you supplied skywalker?

    You can hook the '404_template' filter and return the path to the template you want it to use or false if you don't want any output.

    function override_404_template( $template ) {

    return '/var/www/errors/404.php';

    }

    add_filter('override_404_template', '404_template');
    Copy linkTweet thisAlerts:
    @NightShift58May 08.2009 — The code below is a two-part sequence, closely related but independent in a way. It is only of any use to you within the Wordpress framework.

    In the Wordpress core files, a number of so-called "hooks" have been defined. These "hooks" are there for you to extend or modify the functionality of Wordpress without having to change Wordpress itself (i.e. without editing the core files).

    The following line, theoretically, would enable you to define one of your functions to "hook" into Wordpress whenever a decision is being by Wordpress as to which 404 Template to use when a file/document hasn't been found.
    [code=php]add_filter('override_404_template', '404_template'); [/code]
    However, whoever posted that on the Wordpress support site got it backwards. It should read:
    [code=php]add_filter('404_template', 'override_404_template'); [/code]
    What it means is: "Wordpress, whenever you read the spot where a filter hook by the name of '404_template' has been defined, use MY function 'override_404_template()' to deal with whatever needs to be done.

    The following function would be your function, the one that would be called when that specific program location has been reached by Wordpress:

    [code=php]function override_404_template( $template ) {
    return '/var/www/errors/404.php';
    }[/code]

    What will now happen? It means that no matter which other 404 Templates a Wordpress theme may have to handle 404 Errors, the PHP script located at '/var/www/errors/404.php' will now always be used.

    All this is internal Wordpress handling. No .htaccess modification required.
    ×

    Success!

    Help @WhiteDragon spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.28,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...