SitePoint Sponsor

User Tag List

Results 1 to 19 of 19
  1. #1
    SitePoint Wizard nofel's Avatar
    Join Date
    Aug 2007
    Location
    Earth
    Posts
    1,766
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    How to read this expression/what does it mean?

    Hi folks,
    am new to php and i was going through code error and i had error on a line which says
    Code PHP:
     $row = $this->_data[0];
    i don't know how to read this or what is that and what is going on here. can anyone explain what is this?
    All those who wander aren't lost.

  2. #2
    SitePoint Enthusiast
    Join Date
    Sep 2011
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I suppose that _data[0] does no exist. You should check if _data array has members.
    eg
    PHP Code:
    if (isset($this->_data[0]))
            
    $row $this->_data[0]; 

  3. #3
    SitePoint Wizard nofel's Avatar
    Join Date
    Aug 2007
    Location
    Earth
    Posts
    1,766
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    That helped, but the error moves on to the next $row and so on. how do i track this bug so that if $row doesn't exist it doesn't show at all. more important how do i get to read the my posted query in plain English
    All those who wander aren't lost.

  4. #4
    SitePoint Enthusiast
    Join Date
    Sep 2011
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could you post the source code?

  5. #5
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    69 Post(s)
    Tagged
    0 Thread(s)
    "What does it mean".

    The line reads as:

    Assign to $row the value of this object's _data array (the _ at the start indicates that this element is considered "Private" to the object), pulling from the first element of the array.

    Based on it being assigned to something called $row, i'm assuming _data[0] is itself an array.

  6. #6
    SitePoint Wizard nofel's Avatar
    Join Date
    Aug 2007
    Location
    Earth
    Posts
    1,766
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by gvre View Post
    Could you post the source code?
    code itself is very long, However i can post few line which jump error to next one.
    Code PHP:
            if (isset($this->_data[0]))
    {
            $row = $this->_data[0]; 
    }
            //
            //$row = $this->_data[0];
             $id = $row->id;
             $user_id = $row->user_id;
              $name = $row->name;
              $subscriptionId = $row->subscriptionId;
              $customerPaymentProfileId = $row->customerPaymentProfileId;
    thats the code,How do i know if $row is set or not.to check its value b4 it get to these lines?
    All those who wander aren't lost.

  7. #7
    SitePoint Wizard nofel's Avatar
    Join Date
    Aug 2007
    Location
    Earth
    Posts
    1,766
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by StarLion View Post
    "What does it mean".

    The line reads as:

    Assign to $row the value of this object's _data array (the _ at the start indicates that this element is considered "Private" to the object), pulling from the first element of the array.

    Based on it being assigned to something called $row, i'm assuming _data[0] is itself an array.
    My wild guess is that maybe its a local variable and not global? if so how can i see what's going on and if its local or global? any string or array function i can use?
    All those who wander aren't lost.

  8. #8
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    69 Post(s)
    Tagged
    0 Thread(s)
    Without seeing the class definition of the object in question, it will be hard to answer your question, but;

    Check the Constructor of the class (function __construct) to see if it puts any data into _data[0] by default.

    If so, we'll need to see the whole class cause something's going wrong. (Stop here.)
    If not, check to see if there's a method to add a row of data to the object. (Continue below)

    If not, you've got a very bad class.
    If so, you'll need to add data to the object before trying to call whatever method you're describing above.

  9. #9
    SitePoint Wizard nofel's Avatar
    Join Date
    Aug 2007
    Location
    Earth
    Posts
    1,766
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    as i am newbie so don't know about classes n constructor. what i understand from what ur saying is to look for a function __construct(found that) in which data has been defined or called?
    All those who wander aren't lost.

  10. #10
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    69 Post(s)
    Tagged
    0 Thread(s)
    What does the constructor function define _data with?

  11. #11
    SitePoint Wizard nofel's Avatar
    Join Date
    Aug 2007
    Location
    Earth
    Posts
    1,766
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by StarLion View Post
    What does the constructor function define _data with?
    here in the construct function
    Code PHP:
        function __construct() {
            parent::__construct();
            global $mainframe, $option;
            $user = & JFactory::getUser();
            $this->_myuser = & $user;
            $this->_user_id = $user->id;
     
            //echo "<br>".$user->name;exit;
        }
    All those who wander aren't lost.

  12. #12
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    69 Post(s)
    Tagged
    0 Thread(s)
    so it doesnt fill in the data at all.... unless it's parent class does

    is there an add data function?

  13. #13
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    69 Post(s)
    Tagged
    0 Thread(s)
    EDIT: or better, is there somewhere we can find this class you're using?

  14. #14
    SitePoint Wizard nofel's Avatar
    Join Date
    Aug 2007
    Location
    Earth
    Posts
    1,766
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by StarLion View Post
    EDIT: or better, is there somewhere we can find this class you're using?
    here is text file of that php file
    All those who wander aren't lost.

  15. #15
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    69 Post(s)
    Tagged
    0 Thread(s)
    and which function are you calling that generates this error?

  16. #16
    SitePoint Wizard nofel's Avatar
    Join Date
    Aug 2007
    Location
    Earth
    Posts
    1,766
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Code PHP:
     getPayInfo()
    where variables are assigned to $row
    All those who wander aren't lost.

  17. #17
    SitePoint Wizard nofel's Avatar
    Join Date
    Aug 2007
    Location
    Earth
    Posts
    1,766
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    To what i can comprehend is that if user doesn't have any info like data information this error pop up.?
    All those who wander aren't lost.

  18. #18
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    69 Post(s)
    Tagged
    0 Thread(s)
    Interesting function that one. It does
    Code:
    		if (isset($this->_data[0]))
    
            $row = $this->_data[0];
    but doesnt give an else.... so it's expecting data to have been returned by the buildQuery and getList...

    buildQuery on pay_info should query out

    SELECT * FROM #__br_user WHERE user_id=" . $this->_user_id

    (Not sure what #__br_user means in this context, but it seems to be a Joomla templating fixer)

    Only thing i can think of at this point is check your database to see if said table has any data for that user?

  19. #19
    SitePoint Wizard nofel's Avatar
    Join Date
    Aug 2007
    Location
    Earth
    Posts
    1,766
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by StarLion View Post
    Only thing i can think of at this point is check your database to see if said table has any data for that user?
    I thought of that too and while i waited for your reply i was putting if statement with isset as gvre said (thanks gvre) and the logic which came into my mind was same as u mentioned that user might have not filled the fields.
    Thanks for the help guys !
    All those who wander aren't lost.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •