1

I'm currently getting undefined-index with the following line in my view

<?php echo $contentMangement['cms_name']; ?>

I am getting the information fine from the DB

enter image description here

Can someone explain why I am getting this error?

1
  • The screenshot isn't clear about what is being dumped, is that $contentManagement? Maybe you need $contentManagement[0]->cms_name Commented Aug 5, 2012 at 23:12

5 Answers 5

1

Because the index is 0. And then the attribute off that is cms_name.

$contentManagement[0]->cms_name
Sign up to request clarification or add additional context in comments.

Comments

1

seems that you are dealing with an array of objects. Try:

<?php echo $contentMangement[0]->cms_name; ?>

Comments

1

Or maybe this could help :

<?php
error_reporting(E_ALL & ~E_NOTICE);
?>

Comments

0

Try calculating the size of the array first, before explicitly retrieving an array's value with that index

Comments

0

$contentManagement looks like it's an array of objects. Objects don't use bracket notation ([]), but rather arrow notation (->).

So first, you'll have to get the element of the one-item array:

$object = $contentManagement[0];

And then you can access the cms_name property of that object:

$value = $object->cms_name;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.