Note that there are some explanatory texts on larger screens.

plurals
  1. POfunction to dynamic insert to Database using mysqli prepare
    primarykey
    data
    text
    <p>i need help with my function thet i build , i trying to use MYSQLI prepare but i am not so good .</p> <p>this is my function :</p> <pre><code> function insertToDb($table,$rowsarray,$valuequestionmarks,$lenstrings,$valarray){ $this-&gt;mysqli-&gt;set_charset("utf8"); if ($insert_stmt = $this-&gt;mysqli-&gt;prepare( "INSERT INTO $table ($rowsarray) VALUES ($valuequestionmarks)" )) { $insert_stmt-&gt;bind_param("$lenstrings",$valarray); // Execute the prepared query. if(!$insert_stmt-&gt;execute()) { die("Execute failed: (" . $insert_stmt-&gt;errno . ") " . $insert_stmt-&gt;error); } } } </code></pre> <p>And this is how i call :</p> <pre><code> $img = "something.jpg"; $uip = ulUtils::GetRemoteIP(false); $table='forgotpassqm'; $rowsarray = 'email,text,img,ip'; $valuequestionmarks ='?,?,?,?'; $lenstrings ='ssss'; $valarray ='$email,$text,$img,$uip'; $func-&gt;insertToDb($table,$rowsarray,$valuequestionmarks,$lenstrings,$valarray); </code></pre> <p>And i keep get this error :</p> <pre><code> Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables </code></pre> <p>And the execute error : </p> <pre><code>Execute failed: (2031) No data supplied for parameters in prepared statement </code></pre> <p>i tryed allot of combination none work , i read other question none as my , and none worked or help either.</p> <p>And i know this is about the ssss , but i using 4 and its seem to be alright so where i wrong here ? Thanks allot.</p> <p>EDIT : </p> <pre><code>$table output : forgotpassqm . $rowsaray output: email,text,img,ip . $valuequestionmarks output : ?,?,?,? . $lenstrings output: ssss. $valarray output: $email,$text,$img,$uip. </code></pre> <p>I think the problem is at $valarray.</p>
    singulars
    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.
 

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