Click here to Skip to main content
14,870,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am making a simple test with PHP and SQL, but I ran into this problem:

Notice: Array to string conversion in /storage/ssd4/795/13427795/public_html/blogposthandle.php on line 7 Array.

$link = mysqli_connect("Localhost","username","passowrd","name");

  $sql = 'SELECT * FROM pizza';
  $result = mysqli_query($link, $sql);
  $pizzas = mysqli_fetch_all($result);
  echo $pizzas;

What I have tried:

Can anyone please tell me what I am doing wrong?
Updated 10-Mar-21 3:44am
Patrice T 8-Oct-20 22:02pm
Code is 6 lines, but error is on line 7 or 11 ??

1 solution

Because you can't use echo to output a whole array, you have to use a loop:
$colours = array("Red", "Green", "Blue");
foreach($colours as $value){
    echo $value . "<br>";

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900