title: Uncaught TypeError: mysqli_query(): Argument #2 ($query) must be of type string, mysqli_stmt given in PHP
body: <p>I created a prepared statement in my PHP script but when I submit my form to insert, I get this error, <code>Fatal error: Uncaught TypeError: mysqli_query(): Argument #2 ($query) must be of type string, mysqli_stmt given in C:\xampp\htdocs\7058\insert.php:100 Stack trace: #0 C:\xampp\htdocs\7058\insert.php(100): mysqli_query(Object(mysqli), Object(mysqli_stmt)) #1 {main} thrown in C:\xampp\htdocs\7058\insert.php on line 100</code>.</p>
  <p>It is my first time trying prepared SQL statements, so I am not sure what I am doing wrong.</p>
  <pre><code>&lt;?php
          session_start();
          // servername =&gt; localhost
          // username =&gt; root
          // password =&gt; empty
          // database name =&gt; staff
          $conn = mysqli_connect(&quot;localhost&quot;, &quot;root&quot;, &quot;&quot;, &quot;survey&quot;);
          // Check connection
          if ($conn === false) {
              die(&quot;ERROR: Could not connect. &quot;
                  . mysqli_connect_error());
          }
          $name = $_SESSION['name'];
          $paygoid = $_SESSION['paygoid'];
          $product_exist_satisfaction = $_SESSION['product_exist_satisfaction'];
          $system_battery_runout = $_SESSION['system_battery_runout'];
          $rank_appliances = $_POST['rank_appliances'];     //return an array.
          $checkboxvalue = implode(&quot;,&quot;, $rank_appliances);
  
  
          $sql = $conn-&gt;prepare(&quot;INSERT INTO cus_survey (name,paygoid,product_exist_satisfaction,system_battery_runout,rank_appliances)  VALUES (?, ?, ?, ?, ?)&quot;);
          $sql-&gt;bind_param(&quot;sssss&quot;, $name, $paygoid, $product_exist_satisfaction, $system_battery_runout, $checkboxvalue);
          if (mysqli_query($conn, $sql)) { **//this is line 97**
              echo &quot;&lt;h3&gt;Your survey was captured successfully. Thank You!&quot;           
          } else {
              echo &quot;&lt;h3&gt;Sorry, Your ID has already been used. Please enter a valid ID&lt;/h3&gt; &quot;
              echo &quot;&lt;h3&gt;&lt;a href='/7058/index.php'&gt;Click here to edit your ID&lt;/a&gt;&lt;/h3&gt;&quot;;
          }
  
          // Close connection
          mysqli_close($conn);
          ?&gt;
  </code></pre>