Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You're missing semi-colons in your mutli-query statement.</p> <p>You can add them in front of the queries you are concatenating (<code>.=</code>) for consistency, since the if statement may or may not add a query into the mix.</p> <pre><code>//insert user input into db $query = "INSERT INTO test_details (test_title, user_id, likes) VALUES ('$title', '$user_id', '0')"; $query .= ";INSERT INTO test_descriptions (test_id, description) VALUES (LAST_INSERT_ID(), '$description')"; if(isset($grade) &amp;&amp; isset($difficulty) &amp;&amp; isset($subject)) { $query .= ";INSERT INTO test_descriptions (test_id, grade, subject, difficulty) VALUES (LAST_INSERT_ID(), '$grade', '$subject', '$difficulty')"; } if(mysqli_multi_query($con, $query)) { echo 'Go &lt;a href="../create"&gt;back&lt;/a&gt; to start creating questions.'; } else { echo "An error occurred! Try again later."; echo mysqli_error($con); } </code></pre> <p>Or as andrewsi mentioned, the implode method:</p> <pre><code>//insert user input into db $query[] = "INSERT INTO test_details (test_title, user_id, likes) VALUES ('$title', '$user_id', '0')"; $query[] = "INSERT INTO test_descriptions (test_id, description) VALUES (LAST_INSERT_ID(), '$description')"; if(isset($grade) &amp;&amp; isset($difficulty) &amp;&amp; isset($subject)) { $query[] = "INSERT INTO test_descriptions (test_id, grade, subject, difficulty) VALUES (LAST_INSERT_ID(), '$grade', '$subject', '$difficulty')"; } if(mysqli_multi_query($con, implode( ';', $query ))) { echo 'Go &lt;a href="../create"&gt;back&lt;/a&gt; to start creating questions.'; } else { echo "An error occurred! Try again later."; echo mysqli_error($con); } </code></pre>
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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