OK, so i have mod'ed the script to make several queries to the db and place each set of results into a seperate array. I then want to join the arrays into one. However before I proceeded to do that I tried to echo a few of the values and they are empty. Can anyone see what is wrong with this?
Thanks
$db_servername = "localhost";
$db_username = "cactiuser";
$db_password = "password";
$db_navn = "cacti";
$query_id = "select id from host" ;
$query_name = "select hostname from host";
$query_ip = "select management_ip from host";
$query_user = "select snmp_username from host";
$query_pass = "select snmp_password from host";
$telnet_array = array();
$id_array = array();
$name_array = array();
$ip_array = array();
$user_array = array();
$pass_array = array();
$count_0 = 0;
$count_1 = 0;
$num_0 = 0;
$num_1 = 0;
$Error_query = "Unable to perform query";
$Error_fetch = "Unable to perform fetch";
/ connect to db , check connection /
@ $db = mysql_pconnect("$db_servername" , "$db_username" , "$db_password");
if (!$db)
{echo "Error: Could not connect to database";
exit;
}
/ query db , store data in array, count number of entires /
mysql_select_db("$db_navn") or die ("Unable to select database \n");
$result = mysql_query($query_id) or die ("$Error_query"."\n");
$id_array = mysql_fetch_array($result) or die ("$Error_fetch"."\n");
$num_results = mysql_num_rows($result) or die ("Unable to count rows \n");
$result = mysql_query($query_name) or die ("$Error_query"."\n");
$name_array = mysql_fetch_array($result) or die ("$Error_fetch"."\n");
$result = mysql_query($query_ip) or die ("$Error_query"."\n");
$ip_array = mysql_fetch_array($result) or die ("$Error_fetch"."\n");
$result = mysql_query($query_user) or die ("$Error_query"."\n");
$user_array = mysql_fetch_array($result) or die ("$Error_fetch"."\n");
$result = mysql_query($query_pass) or die ("$Error_query"."\n");
$pass_array = mysql_fetch_array($result) or die ("$Error_fetch"."\n");
/ build arrays for telnet /
/ while ($count_0 <= $num_results) /
/i { /
/ $telnet_array[$num_0][0] = $array["id"]; /
/ $telnet_array[$num_0][1] = $array["management_ip"]; /
/ $telnet_array[$num_0][2] = $array["snmp_username"]; /
/ $telnet_array[$num_0][3] = $array["snmp_password"]; /
/ $telnet_array[$num_0][4] = $array["hostname"]; /
/( $count_0++; /
/ /
/ temp line to show end of script, remove when completed /
echo $name_array[3];
echo $pass_array[1];
echo "<br>End of script";