0

I know that the PHP scripts work because I tested them without jQuery therefore I think something wrong with my jQuery.

<form id="bakery" name="bakery" method="POST" action="bakeryupdate.php">
            <select id="bakeryid" name="bakeryid">
                <option value="">Select</option>
                </select>
<input type="submit" value="Submit" name="submit" id="bakeryupdatebutton" />
</form>

$(document).ready(function() {

        $.ajax({
            type:'POST',
            url:'bakeryupdate.php',
        data: {bakeryid:bakeryid}
        }).done(function(){
            $('#success').text('success!');

        });
    }
        e.preventDefault();
        });    
});

update data php script

<?php       
    if(isset($_POST['submit'])) {

        $sql = "UPDATE bakeryorders SET description='shipped";

        if (mysqli_query($con, $sql)) {

            echo "Bakery order updated";
        } else {
            echo "Error!";
    }
}
?>
19
  • Any error in error console? Commented Feb 11, 2015 at 17:34
  • No errors not showing the selections in options, there should be 4 selections (i tried when i put the selection options code in the form) and when i submit it says success! but doesn't add to database and no errors for this either :( Commented Feb 11, 2015 at 17:36
  • mysqli_real_escape_string() requires DB connection be passed. php.net/manual/en/mysqli.real-escape-string.php - Plus, make sure your submit button has the name attribute. That conditional statement is relying on it. Commented Feb 11, 2015 at 17:38
  • Add or die(mysqli_error($con)) to mysqli_query() and use error reporting php.net/manual/en/function.error-reporting.php - You have enough to debug your code. Commented Feb 11, 2015 at 17:40
  • @Fred-ii- $bakeryid= mysqli_real_escape_string($con,$_POST['bakeryid']) ? Commented Feb 11, 2015 at 17:42

1 Answer 1

1

Make sure to commit the transaction if you don't have autocommit...

mysqli->commit();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.