Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>EDIT: after discussing <a href="https://stackoverflow.com/questions/8630152/php-eval-is-this-exploitable-in-my-code">here click here</a> i decided to use Francis Avila solution, it is securer, but I didn't find a way to exploit my way, only everybody says its security risk to use eval(). If you find a way, to exploit my away, please post a comment. :-), so that i understand it and also another users, who use eval :-)</p> <p>One positive thing, also is in Francis Avila solution is, you need only specific only 2 vars, $SQL + $INPUT, no need more brother with $output.</p> <p>I found a solution: Overview: i used the function eval();</p> <p>1.Step </p> <pre><code>$sql = "SELECT 1, 2, 3 FROM x WHERE b = ? LIMIT 10"; // SQL STATEMENT $input = array("10"); // b = ? from SQL STATEMENT $output = 3; // Number of variables need for 1, 2, 3 </code></pre> <p>2.Step</p> <pre><code>$data = readDB2($sql, $input, $output); var_dump($data); public function readDB2($sql, $input, $output1) { $stmt = $this-&gt;mysqli-&gt;prepare($sql); if(!empty($input) &amp;&amp; is_array($input)) { $sp = ""; $data = ""; $inputn = count($input) - 1; for($i = 0; $i &lt;= $inputn; $i++) { if($i !== $inputn) { $data .= '$input[' . $i . "],"; } else { $data .= '$input[' . $i . "]"; } $sp .= "s"; } $bind = '$stmt-&gt;bind_param(\''. $sp . '\',' . $data . ');'; eval("return $bind"); } if (!$stmt) {throw new Exception($this-&gt;mysqli-&gt;error);} $stmt-&gt;execute(); if (!$stmt) {throw new Exception($this-&gt;mysqli-&gt;error);} $stmt-&gt;store_result(); $checker = $stmt-&gt;num_rows; if($checker !== 0) { if(!empty($output1)) { $out = ""; for($i = 1; $i &lt;= $output1; $i++) { if($i !== $output1) { $out .= '$out' . $i . ","; } else { $out .= '$out' . $i; } } $res = '$stmt-&gt;bind_result(' . $out . ');'; eval("return $res"); $vars = "array(" . $out . ");"; while ($stmt-&gt;fetch()) { $results[] = eval("return $vars"); } } } else { $results = "NO RESULTS"; } $stmt-&gt;fetch(); $stmt-&gt;close(); $this-&gt;results = array('num_rows' =&gt; $checker, $results); return $this-&gt;results; } </code></pre>
    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.
    1. VO
      singulars
      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