Very simple query with implode gives implode: invalid arguments passed
-
14-04-2021 - |
문제
It's friday, so I am obviously not seeing things strait so I thought to ask here.
I want to get a list of names from the database using:
$test = mysql_query("SELECT Names FROM Content ORDER BY Names");
This should give JimMikePeter
(at least it does in PHP MyAdmin)
This is not very readable so I thought, lets implode:
$line = implode( ", ", $test);
echo $line;
This should give: Jim, Mike, Peter
but it doesn't, it gives: Warning: implode() [function.implode]: Invalid arguments passed
Also I want the result like this: "Jim", "Mike", "Peter"
(with quotes)
Any thoughts?
해결책
You have to fetch the array using mysql_fetch_array. Using a query as a parameter in implode() will give you an error
다른 팁
You should know that mysql_query returns a resource documented in the PHP manual you nead to fetch the data with a fetch function like mysql_fetch_array