![]() |
User ID data not showing. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: User ID data not showing. (/showthread.php?tid=69888) |
User ID data not showing. - kirasiris - 01-27-2018 Hello everybody, Can somebody tell me where I got the error in my code? I already tried different queries in my get_userdata method and I even tried $query->result_objec(); but so far I've been unable to display the correct info. This is my user method in User_controller: PHP Code: public function user($id){ This is my get_userdata method in my User_model: PHP Code: public function get_userdata($id) and this is my view in which I need to display the user data according to the user ID: PHP Code: <section class="showcase text-center" style="background: url(<?php if($item->cover_img) : echo $item->cover_img; else : echo base_url().'assets/img/nocoverimage.gif'; endif ?>)no-repeat center center; background-attachment:fixed;"> RE: User ID data not showing. - InsiteFX - 01-27-2018 PHP Code: // Change Greater than 1 means it has to be higher than 1 RE: User ID data not showing. - InsiteFX - 01-27-2018 Here is a helper that will show you nice formatted dumps of arrays etc; PHP Code: // ----------------------------------------------------------------------- Use this to make sure that your queries and data arrays contain values... RE: User ID data not showing. - kirasiris - 01-27-2018 (01-27-2018, 04:56 AM)InsiteFX Wrote: I did as you said so( $query->num_rows() > 0) but I'm still getting errors. PHP Code: $query->row() ; // with $item->username returns a NULL. and all of them (literally) shows this as well: Quote:Trying to get property of non-objectThe way in which I display the values in the view remains the same (e.x : $item->username ; according to the query I have). Thanks for helping. RE: User ID data not showing. - InsiteFX - 01-28-2018 One of the most common fatal errors in PHP is the “call to a member function of anon-object” type. This occurs whenever a method is called on anything other than an object (usually null). Check to make sure that you are getting a value passed for you users ID. Here is a list of the returned query results. PHP Code: /** It sounds like your users ID is not being passed to the method. RE: User ID data not showing. - kirasiris - 01-28-2018 (01-28-2018, 05:17 AM)InsiteFX Wrote: One of the most common fatal errors in PHP is the “call to a member function of anon-object” type. I still get the same error :/ . I will tell you that three columns in my users table can be NULL (avatar_img, cover_img, occupation ,etc) but so far all the users found in that table have everything filled in. The only column which I believe is empty in both users(currently two resgistered users) is the e-mail but I dont even plan to display that value in the front end. Thanks man for helping. I will try to post the same question on StackOverflow ; some of them may know as well. By the way the helper you provided to me is pretty cool. Thnaks. NOTE: I may get back(again; if I dont get it fixed) later on. RE: User ID data not showing. - InsiteFX - 01-29-2018 If this is a method in your controller or model, the view cannot access it without the CI Super Object... PHP Code: <h1><?php echo get_user_full_name($item->user_id); ?></h1> Get back to me and let me know... RE: User ID data not showing. - kirasiris - 02-01-2018 (01-29-2018, 04:04 AM)InsiteFX Wrote: If this is a method in your controller or model, the view cannot access it Hey I'm back(could not get it solved). The method is not actually from any controller of model, it is from a helper I crerated in order to get the first name and last name of the user together. Here it is: PHP Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Thanks for helping I dont want to move further without solving this as this feature(viewing profiles) is pretty much important. |