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 [syntax=php]<?php function topicname()
{
$querylist = mysql_query("SELECT `topicid`,`topicname` FROM `topiclist`");
$topiclist = array();
while ($listresult = mysql_fetch_assoc($querylist))
{
$topiclist[] = $listresult;
}
return $topiclist;
}
?>[/syntax]
My problem is that when I call the function and feed the array into another function
[syntax=php]$topic = topicname();
print_r($topic);
print_r(forumdetails($topic));[/syntax]
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 [syntax=php] $topicid = (int)$listresult['topicid'];[/syntax] so am not sure why it gives me the error
I just wondered if you can help me. I have a function which returns an array [syntax=php]<?php function topicname()
{
$querylist = mysql_query("SELECT `topicid`,`topicname` FROM `topiclist`");
$topiclist = array();
while ($listresult = mysql_fetch_assoc($querylist))
{
$topiclist[] = $listresult;
}
return $topiclist;
}
?>[/syntax]
My problem is that when I call the function and feed the array into another function
[syntax=php]$topic = topicname();
print_r($topic);
print_r(forumdetails($topic));[/syntax]
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 [syntax=php] $topicid = (int)$listresult['topicid'];[/syntax] so am not sure why it gives me the error