Hi i begin to use codeigniter not so long ago and i got small problem.

I try to get comment from db as
            $q = $this->CI->db->query("Select * from comments where item_id = '".$id."' and item='page'");
                 return $q->result_array();
				return false;

Open in new window

and then in view file i just put

<? if(is_array($comments)){
		foreach($comments as $comment){	

<div class="testimonials-item">
        			<p class="testimonials-item-text"><? echo $comment[message];?></p>
        			<p class="testimonials-item-author"><? echo $comment[author];?></p>

<?		}	

Open in new window

but i got problem

A PHP Error was encountered

Severity: Notice

Message: Use of undefined constant message - assumed 'message'

Filename: views/add_comments.php

Line Number: 8

What can make this error. How i can fix it.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

echo $comment[message];

should be

echo $comment['message'];

and 'author' likewise

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
umaximAuthor Commented:
is it requirements of php or why it ask for ''
it's just php syntax.
You specify an array's index either...

1. Using a literal integer:

2. Using a literal string:

3. Using another variable which holds either an integer or a string:
        $index = 0;
        $array[$index];  // same as $array[0]
        $index = "zero";
        $array[$index];  // same as $array["zero"]

4. Using a constant which holds either an integer or a string:
        define('zero', 0);
        $array[zero];  // same as $array[0]

In your case, you are trying to specify a string index, so you need to quote it in order for php to understand you are trying to specify a string and not a constant or a variable.
umaximAuthor Commented:
thanks for explanation.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.