Undefined index on array output
Posted: Tue Oct 16, 2012 2:16 pm
Hi,
I just wondered if you can help me. I have a function which returns an array
I just wondered what I am doing wrong. I have my variable defined as
I just wondered if you can help me. I have a function which returns an array
<?php function topicname()
{
$querylist = mysql_query("SELECT `topicid`,`topicname` FROM `topiclist`");
$topiclist = array();
while ($listresult = mysql_fetch_assoc($querylist))
{
$topiclist[] = $listresult;
}
return $topiclist;
}
?>
My problem is that when I call the function and feed the array into another function
$topic = topicname(); print_r($topic); print_r(forumdetails($topic));It says Notice: Undefined index: topicid in D:\xamppstuff\htdocs\flamebox\internal\func\forumstuff-inc.php on line 14
I just wondered what I am doing wrong. I have my variable defined as
$topicid = (int)$listresult['topicid'];so am not sure why it gives me the error