ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Error 404 when trying to edit a template.

July 16, 2012 3:48pm

Subscribe [1]
  • #1 / Jul 16, 2012 3:48pm

    mangen

    5 posts

    Hello,

    I’m trying to edit a template and give it this text:

    {exp:query sql="SELECT hash FROM exp_user_keys WHERE hash = '{segment_3}'"}     
        {if no_results}
            false
            {if:else}
                true
            {/if:else}
        {/if}
    {/exp:query}

    When I click Update, I get:
    Status: 404 Page Not Found
    A sample URL that this error occurs on is
    site.com/system/index.php?S=bf9f1d635e9713d9cdf1f6d33efc35f5386669a8&D=cp&C=design&M=update_template&tgpref=1

    If I just make the text of the template say “test”, it updates successfully.

    What’s going on here? Thanks!

  • #2 / Jul 16, 2012 6:41pm

    mangen

    5 posts

    Update:

    I managed to find a solution, but I’d still like to know what’s going on behind the scenes causing the problem.

    After doing some testing, I found that it was the phrase “exp_user_keys” that was causing the problem. Even if the query the database using the SQL Manager, that phrase gives me a 404.

    I solved the problem by using PHP AND doing this:

    <?php
    
    $word = "exp_user_keys";
    
    $segment = $this->EE->uri->segment(3);
    
    $query = $this->EE->db->query("SELECT hash FROM $word WHERE hash = '".$this->EE->db->escape_str($segment)."'");
    
    if ($query->num_rows() > 0) {
     echo "true";
    } else {
     echo "false"; 
    }
    
    ?>
  • #3 / Jul 17, 2012 4:24pm

    Kevin Smith

    4784 posts

    Hi mangen,

    Welcome to the forums! I suppose I’m confused about what you’re trying to accomplish here. What is the exp_user_keys table? I don’t believe that’s something from a default EE installation. Where is the hash coming from? And were you seeing any errors when you tried the first example?

    The “if no results” conditional you have isn’t properly formed either. It’s just a simple conditional, as noted here. Anything outside that will display if there are results, anything inside that tag pair will display if there aren’t any results. Make sense?

  • #4 / Jul 17, 2012 6:13pm

    mangen

    5 posts

    The exp_user_keys table is generated by Solspace User. Hashes are generated by a form that I submit which ties the hash to an email address. I didn’t see any error.

    Thanks for the tip on the if no_results tag. I was a bit surprised that there were no examples of an else tag for it, so that makes more sense.

    Thanks!

  • #5 / Jul 17, 2012 11:33pm

    mangen

    5 posts

    Another update:

    I’ve pretty much confirmed that the problem isn’t related to Solspace User. There seems to be something raducally wrong with either my installation or my database. I’ve tried repairing and optimizing tables, but no dice.

    I created a global variable called admin_header with this text:

    <a href="http://../../data_entry/">x </a>

    And I’m getting the same error.

    However, if I edit the global variable to:

    <a href="http://../data_entry/">x </a>

    It works. It either works or does not work respectively every time. What could possibly be the problem?

  • #6 / Jul 18, 2012 2:37pm

    Kyle Cotter

    730 posts

    Hi mangen!

    Sorry to see you’re encountering these issues.

    The first thing that comes to mind when reading through your issue is it’s a mod_security issue.

    Perhaps your host has some security settings in place that are affecting your ability to save templates.

    Certainly, if it works with some words and phrases but not with others, mod_security is the first thing that pops in to mind.

    Could you check with your host and see what kind of security settings are in place, and see if per chance, that’s the reason why when you include certain strings of text and code, you can’t save?

    Keep me posted.

    Thanks!

  • #7 / Jul 19, 2012 10:51am

    mangen

    5 posts

    Kyle,

    It was indeed a mod_security issue. A quick talk with my host got the problem fixed. Thanks!

  • #8 / Jul 19, 2012 4:46pm

    Kevin Smith

    4784 posts

    Great! Glad to hear Kyle was able to get you squared away. Let us know if we can help again in the future!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases