Can anyone tell me what's wrong with my code? I get the error message "Warning: join() [function.join]: Invalid arguments passed in..." on the very last line - echo join( $URL, '
' );
I checked this discussion and this one, but nothing clicks. I pasted my query into phpMyAdmin > SQL, and it works perfectly, returning a table with two columns listing values in the field URL that have multiple instances along with the number of instances (e.g. Bill_Gates | 4).
So it looks like there must be a problem with my code - unless there's a bug in a file higher up the food chain, but I don't think that's likely.
$stm = $pdo->prepare("select URL, count(*)
from ((SELECT 'GZ' AS GSiteID, NULL as Site, 'Life' AS GSection, GZL.Taxon AS URL
FROM gz_life GZL WHERE GZL.Taxon = :MyURL
) UNION ALL
(SELECT 'All' AS GSiteID, NULL as Site, 'World' AS GSection, GG.Name AS URL
FROM gw_geog GG WHERE GG.Name = :MyURL
) UNION ALL
(SELECT 'PX' AS GSiteID, Site, 'People' AS GSection, Ppl.URL
FROM people Ppl WHERE Ppl.URL = :MyURL
)
) t
group by URL
having count(*) > 1;");
$stm->execute(array(
'MyURL'=>$MyURL
));
while ($row = $stm->fetch())
{
$URL = $row['URL'];
}
echo join( $URL, '<br>' );
P.S. I posted var_dump($URL); at the very end of the above script, but it only displays string(9) "Zachaenus", which doesn't make any sense to me. (I think Zachaenus is a scientific name from the table Life.) But I've never used var_dump before so maybe I'm not doing it correctly.
You need to make use of the glue parameter first.
echo join( '<br>',$URL );
^^^^^ ^^^^ //<---- Order Interchanged
Alternatively, you could make use of implode
which does the same of the join.
Secondly.. the $URL
must be array.
$URL = array();
while ($row = $stm->fetch())
{
array_push($URL,$row['URL']);
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments