0

I am trying to fetch a row from my mysql DB using mysqli query.

PHP

$_SESSION['orderID'] = "632";
$orID = $_SESSION['orderID'];
$sql = $db->prepare('SELECT * FROM order_list WHERE order_id = ? ');
$sql->bind_param('s',$orID);
$sql->execute();
while($row = $sql->fetch()) 
{
   $productid = $row[0];
   $name = $row[1];
   echo $price = $row[2];

}

give no error in console and no result,

I have been trying to check the answers on stack overflow, I also googled it but all the suggestions gives me the same error.

I am pretty new with mysqli, your help will be highly appreciated

1
  • which particular answers did you try? Commented Apr 1, 2014 at 10:16

1 Answer 1

1

mysqli_fetch_array is a mysqli_result method not a mysqli_stmt one

You could use ->fetch() upon a mysqli_stmt

So basically your code could change that way

while($sql->fetch()) {
 //do something
}

but you need to call bind_result() before looping (otherwise you can't access returned values)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.