Autor Subiect: Fatal error: Using $this when not in object context in ...  (Citit de 7267 ori)

SeerKan

  • Membru
  • ***
  • Mesaje postate: 325
  • Karma: +4/-15
    • Vezi Profilul
    • HostHash
Fatal error: Using $this when not in object context in ...
« : Martie 10, 2007, 11:01:14 pm »
Fatal error: Using $this when not in object context in C:\HostingSpaces\..... on line 85


Linia 85: echo '<a name="' . $this->form . 'Anchor"></a>';


Context :

$block1 = new block();

echo '<a name="' . $this->form . 'Anchor"></a>';
echo '<form accept-charset="UNKNOWN" method="POST" action="../administration/mycompany.php?action=update" name="adminDForm" enctype="multipart/form-data">';
echo '<input type="hidden" name="MAX_FILE_SIZE" value="100000000">';



Am php 5 pe server.

Daca stiti cumva rezolvarea as fi recunoscator ;)


LATER EDIT: Am rezolvat.

Pentru cei au aceasta problema rezolvarea era :

to fix do the following:
change: $this->form
to: $block1->form

Acest fix e entru cei care ruleaza netoffice pe php5.

Adrian Andreias

  • Webmaster
  • ****
  • Mesaje postate: 595
  • Karma: +13/-0
  • Elvsoft, Cluj-Napoca
    • Vezi Profilul
    • http://www.elvsoft.com/
Fatal error: Using $this when not in object context in ...
« Răspuns #1 : Martie 11, 2007, 08:08:49 pm »
$this are semnificatia "instanta (obiectul) clasei in care te afli".

Cum codul ce dadea eroare nu era intr-o clasa nu avea cum sa functioneze.

steauaboys

  • Vizitator
Răspuns: Fatal error: Using $this when not in object context in ...
« Răspuns #2 : August 25, 2009, 05:10:22 pm »
Salutare,

si eu intampin aceiasi problema :

Fatal error: Using $this when not in object context in /home/rpisci44/public_html/include/lib/items.php on line 227

"function returnCategoryDetails ($categoryId) {

   /*
   *   Requirements: item class
   *   This function return $categoryId's associative SQL-name
   *   Status: Objective
   */
line 227
      if (!$this->db) util::dbInit ();
      if (!$this->categoriesTable) item::tablesInit ($categoryId);

      if (!$this->db->tableExists ($this->categoriesTable)) item::createCategoriesTable ();

      $query =
         'SELECT
"
se pare ca este o incompatibilitate intre php4 si php5, serverul fiind de php5.

orice sfat este binevenit...

Multumesc,

Radu

etp.ro

  • Moderator
  • Webmaster
  • *****
  • Mesaje postate: 825
  • Karma: +8/-0
    • Vezi Profilul
    • http://www.myserver.ro
Răspuns: Fatal error: Using $this when not in object context in ...
« Răspuns #3 : August 25, 2009, 08:16:48 pm »
raspunsul lui Adi era suficient, dar uite si explicatia mai pe larg.


http://www.phpbuilder.com/manual/en/reserved.php


cauta "this".

"this" este variabila reservata incepand cu php5.