Parse error: syntax error, unexpected $end caused by foreach in view |
[eluser]swgj19[/eluser]
Codeigniter Vs. 2.0 Oh right. I basically queried my database in my model. Then in my controller I called my model. And then I called the string as $row in a foreach in my view. I am getting that basic old error and I cannot figure out why. I commented out the foreach on my view and the error goes away. So I know where the error is caused, but cannot figure out how to keep my foreach loop in my view without the error. Thanks guys.. Here is the full error: Parse error: syntax error, unexpected $end in /home/content/70/6930870/html/tt/application/views/logged_in_area.php on line 28 Here is my model: Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Here is my controller Code: <?php Here is my view Code: <!DOCTYPE html>
[eluser]InsiteFX[/eluser]
Missing endforeach. Code: <?php Example: Code: <!-- Xajax pagination Table -->
[eluser]swgj19[/eluser]
Thanks Ray. That was a simple mistake. I am a little rusty. I have a couple more questions. I am trying to break each query result into $row->field_name so I can echo the first name, last name, and email in the user's profile seperately. The way I have it set up now in my query returns every first name from my membership table. So could I do this without a foreach loop? Also, How would I change my query in my model to retrieve only the first name of the user's session, who is logged in in my members area?
[eluser]InsiteFX[/eluser]
1) first name, last name and email Code: function retrieve() 2) Using the query above you already have the first_name Code: $data = $this->model_name->retrive();
[eluser]swgj19[/eluser]
Now I am getting each string from the controller and my first and last name our showing, but I am getting an error: Trying to get property of non-object. I am getting this error for every string I echo in my view which is currently the $first_name and $last_name, Code: function members_area() Code: function retrieve()
[eluser]InsiteFX[/eluser]
Code: function members_area() Just pass the $data to your view then echo Code: <?php echo $first_name; ?>
[eluser]swgj19[/eluser]
That is exactly what I did and I still get the error. I am stating the $first_name etc. in my controller then passing $data in my view in my controller. Then I am simply echoing the $first_name in the view. The queried data passed to the string in the controller is showing in the view. So on my page I am seeing the first name and last name from the database, but with the above error for every string echoed in the view.
[eluser]weboap[/eluser]
what @InsiteFX meaned take off this part from your controller Code: $first_name = $data['first_name']; and leave the function just like Code: //load model then in your view Code: <?php echo $first_name; ?>
[eluser]InsiteFX[/eluser]
That sounds werid, Show me your controller, model and view code that you have now! If you did not change this it should be Code: function members_area()
[eluser]swgj19[/eluser]
Thanks for the clarification. I did what ya said and it worked. Thanks Now this is returning the first row in the table for first name and last name. How would I return the table and row for corresponding logged in session. If you look at my code, I returned the session username when user logs in to my member's area. But how would I return the session profile info for the session being used? |
Welcome Guest, Not a member yet? Register Sign In |