Fetching array Mysql

Asked

Viewed 19 times

-1

The code returns the error Warning: mysqli_fetch_array() expects Parameter 1 to be mysqli_result, string Given in uvas checkout.php on line 262 is the same structure used in other blocks. ???

$c_email = $_SESSION['customer_email'];
$query  = "SELECT * FROM customers WHERE customer_email='$c_email";   
while($row=mysqli_fetch_array($query)) {
    $c_fname = $row['customer_fname'];
}
  • Post line 262 containing the mysqli_fetch_array the error is there

  • while($Row=mysqli_fetch_array($query)) {

1 answer

1

Before the mysqli_fetch_array you should run your sql with the mysqli_query.
Passing your connection to the database as a parameter.

$c_email = $_SESSION['customer_email'];
$sql = "SELECT * FROM customers WHERE customer_email='$c_email";   
$query = mysqli_query($conn,$sql) or die(mysqli_error($conn));
while($row=mysqli_fetch_array($query)) {
    $c_fname = $row['customer_fname'];
}

You can check more examples in the documentation.
https://www.php.net/manual/en/mysqli-result.fetch-array.php

  • Vdd.. Thank you.

  • No, not vdd. Thanks.

  • Is it true or is it not true ?

  • If by the lack of the query ok, but it does not justify some blocks lose the reason.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.