PHP MySQLi Prepared Statement Not Working
mysql, mysqli, php
Solution
Have you tried checking if any statement errors are being thrown? http://www.php.net/manual/en/mysqli-stmt.error.php
Problem
EDIT START So I found the issue with my code. It was the following line ``` if(isset($_REQUEST['faq_submit'])) { ``` I am not sure whats wrong with this line? Why wouldn't it be working properly? EDIT END For some reason my prepared statement isn't working. Also it doesn't seem to be displaying any errors in the error log. Now I am probably just doing something wrong there but I am sure someone here could spot something wrong I did haha... I tried fixing it in a couple different ways and was just unsuccessful so asking here for help is always a good resort! Here is the my php code for adding a question ``` // Required Configuration include_once('required.php'); // double check page was accessed via submit button if(isset($_REQUEST['faq_submit'])) { // get data that sent from form $topic=trim($_REQUEST['faq_topic']); $detail=trim($_REQUEST['faq_detail']); $name=trim($_REQUEST['faq_name']); $email=trim($_REQUEST['faq_email']); // check if all forms are filled out if(!empty($topic) && !empty($detail) && !empty($name) && !empty($email)) { // Validate Email if (filter_var($email, FILTER_VALIDATE_EMAIL)) { // Prepared Insert Statement $stmt = $mysqli->prepare('INSERT INTO forum_question (`topic`, `detail`, `name`, `email`, `datetime`) VALUES (?, ?, ?, ?, ?)'); // Bind Variables To Values $stmt->bind_param('sssss', $topic, $detail, $name, $email, $datetime); // Execute Prepared Statement $stmt->execute(); // Print Results $html = '<div class="alert alert-dismissable alert-success"><button type="button" class="close" data-dismiss="alert">×</button>You <strong>successfully</strong> submited a question to the FAQ bored.</div>'; print($html); // Close Connections and Statement $stmt->close(); // Statement $mysqli->close(); // MySQLi } else { // Email Validation Failed $html = '<div class="alert alert-dismissable alert-danger"><button type="button" class="close" data-dismiss="alert">×</button>Your <strong>email</strong> was invalid.</div>'; print($html); } } else { // If the required items were not filled out print the following $html = '<div class="alert alert-dismissable alert-danger"><button type="button" class="close" data-dismiss="alert">×</button><strong>All</strong> forms are required.</div>'; print($html); } } ``` Here is that required.php file although I have removed some of the login info. ``` $datetime=date("m/d/y h:i"); // Format Date And Time // Connect $mysqli = new mysqli('host', 'user', 'pass', 'db'); // Check Connection if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } ```