Supplied argument is not a valid MySQL r

admin

Administrator
Staff member
I am not sure why I am gettng this error:
"Supplied argument is not a valid MySQL result resource "


I m trying to get an output liek this:
*Group
*Service
*machine 1
* Machine 2
*Other info

Here's the code. Any hint?

thanks


<?php
$usr="usr";
$pwd="pwd";
$db="servinv";
$conn = mysql_connect("localhost", "$usr", "$pwd");

?>

<?php

function getAssocArray($sql) {
$res = mysql_query($sql);
$arr = array();
while ($row = mysql_fetch_array($res)){
$arr[$row["ind"]][] = $row["val"];
}
return $arr;

}

$svr = getAssocArray("SELECT group_name AS ind, machine_name AS val FROM servinv");

$svc = getAssocArray("SELECT group_name AS ind, service_cat AS val FROM
servinv");

$keys = array_merge(array_keys($svc), array_keys($svr));

echo "\n<ul>";
foreach($keys as $ind) {
// group name
echo "\n\t$ind";

// list services
echo "\n\t\t<div class='service'>\n\t\t\t".implode(" | ",$svc[$ind])."\n\t\t</div>";

// list servers
echo "\n\t\t".implode(" | ",
$svr[$ind])."\n\t\t</div>";

echo "\n\t</li>";
}
echo "\n</ul>";

?>
 
Back
Top