-2
 $hasil=mysqli_query($connect, $ambil);
$hasil_id=$hasil['id'];
$hasil_name=$hasil['name'];
$hasil_email=$hasil['email'];
$hasil_comment=$hasil['comment'];

I got this fatal error from the code above, is it something to do with the php version? especialy when using mysqli

0

2 Answers 2

1

Use mysqli_fetch_assoc or mysqli_fetch_array to fetch a result row as an associative array.

query = "SELECT 1";

$result = $mysqli->query($query); $followingdata = $result->fetch_assoc()

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

Comments

0

Edits below. You're trying to use the mysqli result as an array.

  $hasil=mysqli_query($connect, $ambil);
  //Assuming you're expecting a single result
  $hasil = mysqli_fetch_array($hasil); //Create array from first result
  $hasil_id=$hasil['id'];
  $hasil_name=$hasil['name'];
  $hasil_email=$hasil['email'];
  $hasil_comment=$hasil['comment'];

1 Comment

Should specify the resulttype variable as MYSQLI_ASSOC to get the data in associative indices - $hasil = mysqli_fetch_array($hasil, MYSQLI_ASSOC);

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.