1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Fatal error: Cannot re-assign $this in How can i fix it ?

Discussion in 'PHP' started by leandar, May 22, 2009.

  1. #1
    i was trying to install "Shiichan Anonymous BBS" then i got this error

    Fatal error: Cannot re-assign $this in /home/content/p/o/o/site/html/4chan/admin.php on line 557

    line 557 here

    i am using phpbb5
    leandar, May 22, 2009 IP
  2. jestep

    jestep Notable Member Premium Member

    Messages:
    3,486
    Likes Received:
    199
    Best Answers:
    16
    Trophy Points:
    280
    #2
    Don't use the variable name $this. It is reserved, and php thinks you're trying to do something else.
    jestep, May 22, 2009 IP
  3. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,617
    Likes Received:
    101
    Best Answers:
    0
    Trophy Points:
    105
    #3
    this in PHP is simliar to this in C++. Try using different variable names.

    Peace,
    Barti1987, May 22, 2009 IP
  4. leandar

    leandar Well-Known Member

    Messages:
    3,927
    Likes Received:
    108
    Best Answers:
    0
    Trophy Points:
    120
    #4
    hmm ... i don't know anything about php, please you guys explain me how can i fix it ..

    even i don't know whats variable ...
    leandar, May 22, 2009 IP
  5. jestep

    jestep Notable Member Premium Member

    Messages:
    3,486
    Likes Received:
    199
    Best Answers:
    16
    Trophy Points:
    280
    #5
    Where did you get the script from?
    jestep, May 22, 2009 IP
  6. leandar

    leandar Well-Known Member

    Messages:
    3,927
    Likes Received:
    108
    Best Answers:
    0
    Trophy Points:
    120
    #6
    leandar, May 22, 2009 IP
  7. xlcho

    xlcho Guest

    Messages:
    533
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #7
    $this is a keyword that refers to the class from which it's called from. In the code
    Code (Text):
    1. else foreach ($board as $this) {
    replace $this with another variable. When you do that, you must also replace $this within the { and } brackets of the foreach loop.
    xlcho, May 22, 2009 IP
  8. leandar

    leandar Well-Known Member

    Messages:
    3,927
    Likes Received:
    108
    Best Answers:
    0
    Trophy Points:
    120
    #8
    another variable ? where ...

    this is the admin.php look that 557 line

    Attached Files:

    leandar, May 22, 2009 IP
  9. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,617
    Likes Received:
    101
    Best Answers:
    0
    Trophy Points:
    105
    #9
    Search and replace all occurrences $this to $myVar.

    Peace,
    Barti1987, May 22, 2009 IP
    leandar likes this.
  10. leandar

    leandar Well-Known Member

    Messages:
    3,927
    Likes Received:
    108
    Best Answers:
    0
    Trophy Points:
    120
    #10
    Hahaha ... thank you thank you ... its working :):D:p
    leandar, May 22, 2009 IP
  11. joebert

    joebert Well-Known Member

    Messages:
    2,152
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #11
    Something seems seriously wrong here. That's just one of those errors you shouldn't ever be getting in a script you're not actively working on yourself.
    joebert, May 24, 2009 IP
  12. felluahill

    felluahill Peon

    Messages:
    31
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Agreed, any moderate PHP programmer would not make that mistake.

    And when they say replace it with another variable do something like this:

    Code (Text):
    1. else foreach ($board as $subBoard) {
    Then replace every instance of $this in the following code with $subBoard.
    felluahill, May 24, 2009 IP
  13. leandar

    leandar Well-Known Member

    Messages:
    3,927
    Likes Received:
    108
    Best Answers:
    0
    Trophy Points:
    120
    #13
    thanks you guys for the help, problem solved. :)
    leandar, May 24, 2009 IP