Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 18
  1. #1
    Member
    Join Date
    Jul 2007
    Posts
    45
    Member #
    15489

    Guys, I need help with a 406 error

    I have a small little baitsite I tinker with, nothing special. I just enjoy tinkering a little. Well, I have this little script where I upload my bait recipies to the data base. it consists of three parts, a submission page, a confirmation page and a final submission page where the information is saved. Well, it has always worked fine, as simple as it is. At least until today. Suddenly I had issues. I coule submit the data and go to the confirmation(review) page and it all worked fine but when I click to submit it and pass the information to the confirm page I was getting this error:

    ERROR 406
    Not Acceptable
    An appropriate representation of the requested resource /index.php could not be found on this server.

    The funny thing is, the script still works fine if in my bait instructions area, I posted something like this:

    cups on Instant Grits
    3 cups of Quick Grits
    16 ounces of Karo clear syrup
    2 ounces of liquid flavoring like RandW butternut


    But... when I made the information a bit longer, like this:

    cups on Instant Grits
    3 cups of Quick Grits
    16 ounces of Karo clear syrup
    2 ounces of liquid flavoring like RandW butternut


    Mix all the Liquids together and then all the dry parts together.
    Then mix the liquid and dry stuff together.
    This should cast a mile.

    .................................
    This is where I would get the error. It worked great until I added the last three lines and then I got the error.
    The script seems to function fine and always has, but now, it doesn't and that extra info made all the difference. Any ideas on what is causing this?

    Is this some security mod thing? I contacted the hosting company and they said they'd look into it but im not sure how hard they will look. And as reasonably sure this is a problem beyond my control, I cant be positive since im not the pro some of u are. Any thoughts?

  2.  

  3. #2
    Member
    Join Date
    Jul 2007
    Posts
    45
    Member #
    15489

    Update... a little more information

    I have been trying to figure out whats going on. I have found the part in my script the server doesn't seem to like. At least I have discovered that much so maybe you guys can help me.

    on my confirm/review page, the instructions to make the bait like so:

    6 cups on Instant Grits
    3 cups of Quick Grits
    16 ounces of Karo clear syrup
    2 ounces of liquid flavoring like RandW butternut


    Mix all the Liquids together and then all the dry parts together.
    Then mix the liquid and dry stuff together.
    This should cast a mile.


    I have used this in my script to keep the structure:
    $baitinstruct = trim(str_replace("\n","<br />",$baitinstruct));

    And this seems to be whats causing the issue. It never has before but now it does.
    I tried changing to just this to see what comes of it:
    $baitinstruct = trim(strip_tags($baitinstruct));

    Of course, this works. But the problem as you can imagine is that All my sentences run together. There are no breaks in the recipe. Are there any other ways to do this that the server might accept since some sort of change has obviously occurred?

  4. #3
    Member
    Join Date
    Jul 2007
    Posts
    45
    Member #
    15489

    I even tried

    I even tried this:

    $baitinstruct = str_replace("\n","<br />",$baitinstruct);

    This keeps the structure but when I pass this to the next page I get the error, unless I make the text very short like this:

    6 cups on Instant Grits
    3 cups of Quick Grits
    16 ounces of Karo clear syrup
    2 ounces of liquid flavoring like RandW butternut

    When I ad this rest, the str_replace gives me the error. Not sure why. Maybe im just an idiot and im missing something important. str_replace is causing some sort of issue.

  5. #4
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,689
    Member #
    5580
    Liked
    717 times
    How are you saving the recipes? In a database (SQL), or in a simple text (.txt) file?

    If you are using SQL (MySQL), what is the column type, example varchar, and any lengths you specified?
    Last edited by mlseim; Apr 26th, 2019 at 05:26 AM.


  6. #5
    Member
    Join Date
    Jul 2007
    Posts
    45
    Member #
    15489
    Its MySQL. It was working fine 2days ago and I havnt changed anything but now im having issues. I took a pic of the column type stuff for u.

    photoofbi.jpg

  7. #6
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,689
    Member #
    5580
    Liked
    717 times
    In the last couple of days, did anything get changed in the .htaccess file?

    Looking on Google, it appears the 406 error might be server-related, not sure what that has to do with your scripts, but something to look at.

    https://www.tipsandtricks-hq.com/apa...able-issue-259


  8. #7
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,689
    Member #
    5580
    Liked
    717 times
    Can you post your PHP script that fails when displaying the bait recipe?


  9. #8
    Member
    Join Date
    Jul 2007
    Posts
    45
    Member #
    15489

    I appreciate your help

    i had searched goodle and found the same thing you found. I dont use wordpress, everything i do is written in notepad++. And I dont know too much about htaccess files. Thats kinda new territory for me. There isnt one in the site directory but in my main root directory there is one. I didnt place it there and have no idea how long its been there. I only work on this stuff on ocassion so it could been there a eyar or just two days. but here is whats in it:

    # Begin cache control #
    ExpiresActive on
    ExpiresActive off
    <FilesMatch ".*">
    Header unset Cache-Control
    Header unset Expires
    Header unset Last-Modified
    FileETag None
    Header unset Pragma
    </FilesMatch>
    # End cache control #



    I really don't know what most of that means or if it has anything to do with my issue. And like I said, the script works fine until I ad more text. Which just two days ago was not an issue, but suddenly it is.

    As far as I can tell my issue seems to be in trying to pass after str_replace but who knows.

    I'll try and share the confirm or save page for you but my php is not very advanced. I'm sure its a crude example compared to the pros around here. Let me see if I can figure out how to post it here, 1 sec.

  10. #9
    Member
    Join Date
    Jul 2007
    Posts
    45
    Member #
    15489

    Here is the save page

    <div id="maincontactussub1">
    <?php
    require_once('Bm/checkloggedin.inc.php');
    ?>
    <br />
    <center style="background-color: #262626;">
    <span style="color: #ff4500; background-color: #262626;">
    Bm Save Submission Page
    </span>
    </center>
    <?php
    require_once(DB);
    ?>

    <?php //check to see if variables exist
    if ($_SERVER['REQUEST_METHOD'] == 'POST') { //Handle the form
    $problem = FALSE;
    $problemtwo = FALSE;

    if (!empty($_POST['authorizeupload']) && (($_POST['authorizeupload']) == ($_POST['answer']))) {

    if (!empty($_POST['baitname']) && !empty($_POST['submittedby']) && !empty($_POST['worldloc']) && !empty($_POST['baitinstruct'])) {

    //Grab and clean the variables
    $baitname = trim(strip_tags($_POST['baitname']));
    $submittedby = trim(strip_tags($_POST['submittedby']));
    $worldloc = trim(strip_tags($_POST['worldloc']));
    $fishtype = ($_POST['fishtype']);
    $watertype = ($_POST['watertype']);
    $waterloc = ($_POST['waterloc']);
    $basetype = ($_POST['basetype']);
    $usetimeday = ($_POST['usetimeday']);
    $usetimeyr = ($_POST['usetimeyr']);
    $baitexp = ($_POST['baitexp']);
    $baitinstruct = ($_POST['baitinstruct']);
    //tried next line to see if it was better, the above line works fine
    //$baitinstruct = trim(strip_tags($_POST['baitinstruct']));
    $addcomments = trim(strip_tags($_POST['addcomments']));
    $authorizedpost = '0';

    print '<center style="background-color: #262626;"><p style="background-color: #262626; color: #3aff14;">Your submission is attempting to save.</p></center>';

    } else {

    print '<p style="background-color: #262626; color: red;">Please use your back button and fill in all fields please. Thank you!</p>';

    $problem = TRUE;

    $problemtwo = TRUE;

    }
    } else {
    print '<center style="background-color: #262626;"><p style="background-color: #262626; color: red;">Your answer to the spam filter question was wrong, please use the back button and retry. Thank you!</p></center>';
    print '<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />';




    $problem = TRUE;

    $problemtwo = TRUE;


    }
    } //Handle the form ended.
    ?>

    <?php
    if (!$problem) {
    if ($_FILES["the_file"]["error"] > 0)
    {
    print '<p style="background-color: #262626; color: red;"> Your photo could not be uploaded because: ';

    //Print a message based upon the error:

    switch ($_FILES['the_file']['error']) {

    case 1:
    print '<span style="background-color: #262626; color: red;">The file exceeds the upload_max_filesize setting in the php ini</span>';
    break;
    case 2:
    print '<span style="background-color: #262626; color: red;">The file exceeds the MAX_FILE_SIZE setting in the HTML form</span>';
    break;
    case 3:
    print '<span style="background-color: #262626; color: red;">The file was only partially uploaded</span>';
    break;
    case 4:
    print '<span style="background-color: #262626; color: red;">No photo was attached</span>';
    break;
    case 6:
    print '<span style="background-color: #262626; color: red;">The temporary folder does not exist</span>';
    break;
    default:
    print '<span style="background-color: #262626; color: red;">Something unforseen happened, please try again</span>';
    break;
    }

    print '.</p>'; //complete the paragraph
    }
    else
    {
    echo "Upload: " . $_FILES["the_file"]["name"] . "<br />";
    echo "Type: " . $_FILES["the_file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["the_file"]["size"] / 1024) . " kB<br />";
    echo "Stored in: " . $_FILES["the_file"]["tmp_name"];
    print '<p style="background-color: #262626; color: #3aff14;">Your photo is being added to your submission. </p>';
    $rand = rand();
    $photoupload = $rand . $_FILES['the_file']['name'];
    $photoupload_type = $_FILES['the_file']['type'];
    $photoupload_size = $_FILES['the_file']['size'];
    $target = GW_UPLOADPATH . $photoupload;
    }
    }
    ?>
    <?php
    //Check to see if the database has a duplicate baitname file before writing to database
    if (!$problem) {
    $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
    $match_query = "SELECT baitname FROM bmtable WHERE baitname = '$baitname'";
    $match = mysqli_query($dbc, $match_query);
    $row = mysqli_fetch_array($match);


    if ($baitname == $row['baitname']) {

    print '<p style="background-color: #262626; color: red;">Your submission has already been saved and cannot be duplicated or you accidentally hit refresh. </p>';
    $problem = TRUE;
    mysqli_close($dbc);

    } else {

    $problem = FALSE;
    mysqli_close($dbc);
    }
    }

    ?>



    <?php //write to database
    if (!$problem) {
    //if (move_uploaded_file($_FILES['the_file']['tmp_name'], $target)) {
    if (!empty($photoupload)) {
    move_uploaded_file($_FILES['the_file']['tmp_name'], $target);
    $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

    //Mysqli escape the data for security
    $baitname = mysqli_real_escape_string($dbc, $baitname);
    $submittedby = mysqli_real_escape_string($dbc, $submittedby);
    $worldloc = mysqli_real_escape_string($dbc, $worldloc);
    $baitinstruct = mysqli_real_escape_string($dbc, $baitinstruct);
    $addcomments = mysqli_real_escape_string($dbc, $addcomments);


    // Write the data to the database with uploaded user photo
    $query = "INSERT INTO bmtable VALUES (0, '$baitname', '$submittedby', '$worldloc', '$fishtype', '$watertype', '$waterloc', '$basetype', '$usetimeday', '$usetimeyr', '$baitexp', '$baitinstruct', '$addcomments', '$photoupload', '$authorizedpost', NOW())";

    $result = mysqli_query($dbc, $query);
    // Confirm success with the user
    echo '<p style="background-color: #262626; color: #3aff14;">Your Submission and photo have been added to the database. It will be available to view as soon as it has been approved by the webmaster.</p>';
    echo '<span style="background-color: #262626; color: #e97800;">Bait Name:</span> ' . $baitname . '<br />';
    echo '<span style="background-color: #262626; color: #e97800;">Submitted By:</span> ' . $submittedby . '<br />';
    echo '<span style="background-color: #262626; color: #e97800;">Instructions:</span><br /> ' . $baitinstruct . '<br />';
    echo '<br /><br />';
    echo '<p style="background-color: #262626;"><img src="' . GW_UPLOADPATH . $photoupload . '" alt="Fishing image" height="940" /></p>';
    echo '<p style="background-color: #262626;"><a href="index.php?=home"><span style="background-color: #262626;">&lt;&lt; Back to Home Page</span></a></p>';
    echo '<p style="background-color: #262626;"><a href="index.php?p=sharemix"><span style="background-color: #262626;">&lt;&lt; Share Another Mix!</span></a></p>';

    mysqli_close($dbc);
    } else {

    $photoupload = 'nofishpic.jpg';

    $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

    //Mysqli escape the data for security
    $baitname = mysqli_real_escape_string($dbc, $baitname);
    $submittedby = mysqli_real_escape_string($dbc, $submittedby);
    $worldloc = mysqli_real_escape_string($dbc, $worldloc);
    $baitinstruct = mysqli_real_escape_string($dbc, $baitinstruct);
    $addcomments = mysqli_real_escape_string($dbc, $addcomments);


    // Write the data to the database with generic Baitmix image
    $query = "INSERT INTO bmtable VALUES (0, '$baitname', '$submittedby', '$worldloc', '$fishtype', '$watertype', '$waterloc', '$basetype', '$usetimeday', '$usetimeyr', '$baitexp', '$baitinstruct', '$addcomments', '$photoupload', '$authorizedpost', NOW())";

    $result = mysqli_query($dbc, $query);
    // Confirm success with the user
    echo '<p style="background-color: #262626; color: #3aff14;">Your Submission has been added to the database. It will be available to view as soon as it has been approved by the webmaster.</p>';
    echo '<p style="background-color: #262626; color: #3aff14;">No photo was added so we submitted a generic picture for you.</p>';
    echo '<span style="background-color: #262626; color: #e97800;">Bait Name:</span> ' . $baitname . '<br />';
    echo '<span style="background-color: #262626; color: #e97800;">Submitted By:</span> ' . $submittedby . '<br />';
    echo '<span style="background-color: #262626; color: #e97800;">Instructions:</span><br /> ' . $baitinstruct . '<br />';
    echo '<br /><br />';
    echo '<p style="background-color: #262626;"><img src="' . GW_UPLOADPATH . $photoupload . '" alt="Fishing image" height="940" /></p>';
    echo '<p style="background-color: #262626;"><a href="index.php?p=home"><span style="background-color: #262626;">&lt;&lt; Back to Home Page</span></a></p>';
    echo '<p style="background-color: #262626;"><a href="index.php?p=sharemix"><span style="background-color: #262626;">&lt;&lt; Share Another Mix!</span></a></p>';

    mysqli_close($dbc);
    }
    } // end of database write

    ?>









    </div><!-- main1 close -->

  11. #10
    Member
    Join Date
    Jul 2007
    Posts
    45
    Member #
    15489
    I had to simply copy and paste it , I tried private messaging you but it took too many parts lol. Hope people don't laugh at my terrible scripting. I'm not a pro that's for sure. Anyway, the I made a note in the first page I sent you where the problem was, you'll see it. If something else is causing it I have no idea.


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:15 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com