undefined index

In this board you can talk about general questions about phpMyFAQ

Moderator: Thorsten

Post Reply
steveCronin
Posts: 11
Joined: Tue Dec 02, 2014 10:52 pm
Location: Austin, TX

undefined index

Post by steveCronin » Thu Dec 04, 2014 6:00 am

I'm using a pattern from faq.php to retrieve data

$newFAQParams = $faq->getNewFAQList();
var_dump($newFAQParams);
var_dump(isset($newFAQParams['url']));
var_dump(array_key_exists('url', $newFAQParams));
if (!isset($newFAQParams['error'])) {
$tpl->parseBlock(
'newRightBox',
'newFAQList',
array(
'newFAQUrl' => $newFAQParams['url'],
'newFAQTitle' => $newFAQParams['title'],
'newFAQVisitCount' => $newFAQParams['visitCount'],
'newFAQLastVisitDate' => $newFAQParams['lastVisitDate']
)
);
} else {
$tpl->parseBlock( 'newRightBox', 'newFAQError',
array(
'errorMsgNewFAQ' => $newFAQParams['error']
)
);
}

Below is the var_dump.
What's confusing to me is that, as you can see in the var_dump below, the newFAQParams array has 3 rows... Each row has array with a key of 'url' but the newFAQParams array does not have such a key...
What am I missing here that allows your existing 'rightBox' code to function?

array(3) { [0]=> array(5) { ["title"]=> string(27) "The first general question?" ["date"]=> string(14) "20141202205611" ["url"]=> string(91) "/phpMyFAQ/index.php?sid=51&lang=en&action=artikel&cat=1&id=1&artlang=en" ["visitCount"]=> string(2) "28" ["lastVisitDate"]=> string(10) "1417553223" } [1]=> array(5) { ["title"]=> string(22) "What about Office 365?" ["date"]=> string(14) "20141202205833" ["url"]=> string(91) "/phpMyFAQ/index.php?sid=51&lang=en&action=artikel&cat=3&id=3&artlang=en" ["visitCount"]=> string(2) "24" ["lastVisitDate"]=> string(10) "1417666494" } [2]=> array(5) { ["title"]=> string(54) "Can I use Apple Mail but use Microsoft's Contacts?" ["date"]=> string(14) "20141202214935" ["url"]=> string(91) "/phpMyFAQ/index.php?sid=51&lang=en&action=artikel&cat=4&id=4&artlang=en" ["visitCount"]=> string(2) "13" ["lastVisitDate"]=> string(10) "1417560148" } }
bool(false)
bool(false)

steveCronin
Posts: 11
Joined: Tue Dec 02, 2014 10:52 pm
Location: Austin, TX

Re: undefined index

Post by steveCronin » Thu Dec 04, 2014 6:28 am

more data:

<h4> {writeNewFAQHeader} <a href="feed/newFAQ/rss.php" target="_blank"><img src="assets/img/feed.png" width="16" height="16" alt="RSS" /></a></h4>
<ol>
[newFAQList]
<li><a href="{newFAQUrl}">{newFAQTitle}</a> <small>({newFAQVisitCount})</small></li>
[/newFAQList]
</ol>


here's a sketch of the output:
New FAQ [\\]
1. ()

Here's the notice I am seeing:
phpMyFAQ notice [8]: Undefined index: url in /home/..../index.php on line 680

steveCronin
Posts: 11
Joined: Tue Dec 02, 2014 10:52 pm
Location: Austin, TX

Re: undefined index

Post by steveCronin » Fri Dec 05, 2014 12:10 am

well ok then

I figured this out..

Here's the 'magic' that I wasn't seeing:

foreach ($resultArray as $row) {
$resultArray['url'][] = $row['url'];
...
}

Post Reply