views:

60

answers:

2

Hello,

This is probably obvious but I'm getting this error:

A PHP Error was encountered

Severity: Notice

Message: Undefined index: outputcards

Filename: controllers/site.php

Line Number: 49

Here's the line in question:

$out['outputcards'] .= $this->load->view('client_view_data',$data, TRUE);

which is inside a for loop, and being used in the view as echo $outputcards.

All works fine, but the error is there at the top.

Any ideas?

Thank you!

+2  A: 

You are concatenating new data to the $out['outputcards'], but the very first time you do this the $out['outputcards'] probably does not exist yet. So if you have a array called $out, before you start the loop that contains that code, simply do a $out['outputcards'] = ""; (assuming you are concatenating strings)

CharlesLeaf
Perfect, thank you! I'll have to wait a few minutes to mark this as correct (10 minutes the orange box says).
Robimp
A: 

before the line there, just add

$out = array();
$out['outputcards'] = '';

should knock it out. or if you are lazy (and i do not suggest or admire this), put a @ infront of the line

@$out['outputcards'] .= $this->load->view('client_view_data',$data, TRUE);
Ascherer
Or why not just do `$out = array('outputcards' => '');` rather than sticking those ugly `@` error suppressors in there (I can't stand it)... Always declare your variables explicitly (IMHO)...
ircmaxell
I agree with the error suppressors comment - I'd rather just fix the problem. I originally tried $out = array(); before the loop, but that didn't work, I was obviously missing a bit. Thanks for the comments.
Robimp
as i said, i dont suggest or admire using the @ in front, but i offered it as a suggestion. the $out = array('outputcards' => ''); works too
Ascherer