What I want is to convert an array to a string so I can display it on my websites. I made a query to select the values id, title, date, auteur. When i use my function I made for this, I get the following error:
Notice: Array to string conversion in /Applications/MAMP/htdocs/beheer/index.php on line 444 Array.
The function is as following:
<?php
include ('connect/connect.php');
function getListContentMain() {
global $con;
$dbname = 'content';
mysqli_select_db($con,$dbname);
$q = "SELECT * FROM main LIMIT 5";
$result = mysqli_query($con,$q);
$ListContentMainData = array();
while($row = mysqli_fetch_array($result)) {
echo $row['id'];
echo $row['title'];
echo $row['date'];
echo $row['auteur'];
}
$ListContentMainData[] = $row;
return $ListContentMainData;
}
?>
$ListContentMainData[] = $row;needs to go inside of your loop.I made a query to select the values id, title, date, auteur...No you didn't. Your query selects every column*, you then display your selection usingechoand return the last$row(again, including all columns) wrapped in another array.