Note that there are some explanatory texts on larger screens.

plurals
  1. POmysqli prepared statement woes
    primarykey
    data
    text
    <p>I'm trying to implement my first prepared statement using mysqli.</p> <p>At the moment I have this:</p> <pre><code>&lt;?php $con = new mysqli('example.com', 'user', 'password', 'database'); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit();} $first = $_GET['firstname']; $last = $_GET['surname']; $dob = $_GET['dob']; $address = $_GET['homeaddress']; $college = $_GET['college']; $emergname = $_GET['emergencyname']; $emergnumber = $_GET['emergencynumber']; $condition = $_GET['condition']; $conditiondetails = $_GET['conditiondetails']; $medication = $_GET['medication']; $medicationdetails = $_GET['medicationdetails']; if($stmt = $con-&gt;prepare("INSERT INTO medical ('forename', 'surname', 'dob', 'address', 'college', 'emergency_name', 'emergency_number', 'condition', 'condition_details', 'medication', 'medication_details') VALUES (:forename, :surname, :dob, :address, :college, :emergencyname, :emergencynumber, :condition, :conditiondetails, :medication, :medicationdetails)")){ $stmt-&gt;bind_param(':forename', $first); $stmt-&gt;bind_param(':surname', $last); $stmt-&gt;bind_param(':dob', $dob); $stmt-&gt;bind_param(':address', $address); $stmt-&gt;bind_param(':college', $college); $stmt-&gt;bind_param(':emergencyname', $emergname); $stmt-&gt;bind_param(':emergencynumber', $emergnumber); $stmt-&gt;bind_param(':condition', $condition); $stmt-&gt;bind_param(':conditiondetails', $conditiondetails); $stmt-&gt;bind_param(':medication', $medication); $stmt-&gt;bind_param(':medicationdetails', $medicationdetails); $stmt-&gt;execute(); $stmt-&gt;close();} ?&gt; </code></pre> <p>I have previously tried a variance using:</p> <pre><code>&lt;?php $stmt = $con-&gt;prepare("INSERT INTO medical ('forename', 'surname', 'dob', 'address', 'college', 'emergency_name', 'emergency_number', 'condition', 'condition_details', 'medication', 'medication_details') VALUES (?,?,?,?,?,?,?,?,?,?,?)") $stmt-&gt;bind_param('sssssssssss', $first...); ?&gt; </code></pre> <p>In both instances I get an error message that the $stmt variable doesn't exist.</p> <p>Any suggestions as to where I'm going wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload