@Your Common Sense. You see that allenbell_nc does not need "... just get rid of all this mess and use PDO," as you suggested. Just because you got the wrong idea about the mysqli extension with prepared statements, this does not mean that others should do away with this at the slightest hint of trouble, rather than performing deep, but painful research. After all, this is what stackoverflow is, isn't it? well researched answers ..
@allenbell_nc - To answer your question, I donβt think your problem is with the use of Wildcards and other things. The problem is your line of code where you are trying to use mysqli_fetch_array()
. This is most likely to cause an error complaining about parameter 1 ($ result), since mysqli_stmt_store_result()
used when you want to later find the number of rows returned from the query, so it returns a boolean value (true or false) and NOT a set of results.
INSTEAD, use mysqli_stmt_bind_result()
after calling the call, then call mysqli_stmt_fetch()
in the while state before finally using array_push()
in the while condition tag, which helps you save and subsequently display the contents of your ASSOCIATIVE array.
QUICK EXAMPLE (Idea presented by Mr. Carson MacDonald @ [http://www.ioncannon.net/programming/889/php-mysqli-and-multiple-prepared-statements/] [1]):
...
$ comments = array ();
$comment_stmt->bind_param('i', $post_id); if ($comment_stmt->execute()) { $comment_stmt->bind_result($user_id); while ($comment_stmt->fetch()) { array_push($comments, array('user_id' => $user_id));
...
I hope this helps, good luck, I asked for the first time, as this is also my first answer - to your project.
source share