Ankündigung

Einklappen
Keine Ankündigung bisher.

function - Fehler

Einklappen

Neue Werbung 2019

Einklappen
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • function - Fehler

    Hallo,

    wir haben ein Programm übernommen was wir jetzt betreuen müssen und dort (wenn man die Fehleranzeige anschaltet) sehe ich folgendes:

    Notice: Trying to get property of non-object in /documents/hoteledit.php5 on line 38
    Warning: get_object_vars() expects parameter 1 to be object, boolean given in /documents/inc/class.localization.inc on line 29
    Warning: Invalid argument supplied for foreach() in /documents/inc/class.localization.inc on line 30
    Notice: Undefined property: Localization::$sDateFormat in /documents/inc/class.localization.inc on line 42
    Da ich noch Anfänger bin und mit Funktionen noch nicht so vertraut bin weis ich nicht was ich tun muss oder soll. Kann da jemand helfen?

    hier die Zeilen:

    Zeile 38 aus hoteledit.php5
    $sResult = $oResult -> sCountryCode;
    Zeile 29 aus function
    $aVars = get_object_vars($oLocalization);
    Zeile 30 aus function
    foreach ($aVars as $sKey => $sValue)
    Zeile42 aus function
    if ($this->sDateFormat =="%d.%m.%Y")

  • #2
    Du postest den Code aus /documents/inc/class.localization.inc, nicht aber den der ersten Meldung aus /documents/hoteledit.php5

    Kommentar


    • #3
      nein das ist die Funktion die in einen extra Ordner liegt und so heißt:
      class.localization.inc

      leigt im inc ordner der wiedeerum im documents Ordner leigt

      Kommentar


      • #4
        Upss sorry hast recht hier der Code aus hoteledit

        Zeile 38 ist: $sResult = $oResult -> sCountryCode;


        PHP-Code:
        // Localization

         

            
        if (isset ($_SESSION["iCountryId"]))

            {

                
        $sSql "SELECT sCountryCode FROM ";

                
        $sSql.= C_COUNTRY_TABLE." ";

                
        $sSql.= "WHERE ".C_COUNTRY_TABLE.".iId='".$_SESSION["iCountryId"]."'";

                
        $oResult $GLOBALS["oDatabase"] -> getObjectFromSql($sSql);

                
        $sResult $oResult -> sCountryCode;

               

                
        $oLocal = new Localization ($sResult$oDatabase);

            } 

        Kommentar


        • #5
          also der erste fehler koennte an der definition fehlschlagen
          PHP-Code:

                  $this
          ->oLocalizationList = new ObjectListDb($this -> oDatabaseC_LOCALIZATION_TABLE);      //<-- hier wird C_LOCALIZATION_TABLE uebergeben, musst die mal hier ausgeben und gucken ob was drin steht, weil wenn nein, dann schlaegt der query fehl, dieser liefert ein false
                  
          $aWhere = array ("sId" => $sCountryCode);
                  
          $oLocalizationList $this->oLocalizationList;       
                  
          $oLocalization $oLocalizationList->getObject($aWhere);
                  
          $aVars get_object_vars($oLocalization); //<-- hier wird objekt erwartet steht aber false 
          hier kannste vorher mit is_array($aVars) pruefen ob $aVars ein array ist und erst dann das foreach anwenden
          PHP-Code:
             foreach ($aVars as $sKey => $sValue
          und wenn du unter
          PHP-Code:
          var $sCountryCode
          noch
          PHP-Code:
          var $sDateFormat
          einfuegst, sollten alle notices ausgeschaltet sein
          apt-get install npm -> npm install -g bower -> bower install <package> YOLO [URL]https://www.paypal.me/BlackScorp[/URL] | Mein Youtube PHP Kanal: [url]https://www.youtube.com/c/VitalijMik[/url]

          Kommentar


          • #6
            vielen Dank schon einmal
            eine Fehlermeldung konnte ich schon eliminieren (das mit den var $sDateFormat; einfügen hat geklappt)

            Das andere muss ich mir mal anschauen bzw. recherchieren wie man das macht da ich noch Anfänger bin.

            Ich denke da ist der Wurm drin. Blöd halt uns wurde das so übergeben und wir haben das vorher nicht gesehen da die Fehleranzeige ausgeschalten war. Ich habe auch noch mehr Fehler die wahrscheinlich alle zusammenhängen gefunden - überall wird sLang gesucht.

            Notice: Undefined index: sLang in /documents/citylocedit.php5 on line 339
            Notice: Undefined index: sLang in /documents/citylocedit.php5 on line 340

            Code dazu:
            $aTplVar["aMainMenu"] = getMainMenuItems($_SERVER["PHP_SELF"], $_SESSION["sLang"], $oUser->aFunctions);
            $aTplVar["aMenu"] = getMenuItems($_SERVER["PHP_SELF"], $_SESSION["sLang"], $oUser->aFunctions);

            Notice: Undefined index: sLang in /documents/locsysedit.php5 on line 337
            Notice: Undefined index: sLang in /documents/locsysedit.php5 on line 338

            Code dazu:
            $aTplVar["aMainMenu"] = getMainMenuItems($_SERVER["PHP_SELF"], $_SESSION["sLang"], $oUser->aFunctions);
            $aTplVar["aMenu"] = getMenuItems($_SERVER["PHP_SELF"], $_SESSION["sLang"], $oUser->aFunctions);

            Notice: Undefined index: sLang in /documents/commentman.php5 on line 215
            Notice: Undefined index: sLang in / documents/commentman.php5 on line 216

            Code dazu:
            $aTplVar["aMainMenu"] = getMainMenuItems($_SERVER["PHP_SELF"], $_SESSION["sLang"], $oUser->aFunctions);
            $aTplVar["aMenu"] = getMenuItems($_SERVER["PHP_SELF"], $_SESSION["sLang"], $oUser->aFunctions);
            ich denke das kommt alles von der function die nicht richtig ist

            Kommentar


            • #7
              ich muss noch einmal nachfragen:ich habe jetzt in der funktion den Code
              print_r ($this);
              print_r ($aWhere);
              eingefügt und erhalte jetzt folgende Fehlermeldung auf der hoteledit.php5 seite

              Notice: Trying to get property of non-object in /documents/hoteledit.php5 on line 38
              Localization Object ( [sCountryCode] => [sDateFormat] => [oDatabase] => Database Object ( [iLink] => Resource id #32 [sName] => db5266XXXXX [sHost] => localhost:/tmp/mysql5.sock ) [oLocalizationList] => ObjectListDb Object ( [sTableName] => cta_localization [oDatabase] => Database Object ( [iLink] => Resource id #32 [sName] => db5266XXXXX [sHost] => localhost:/tmp/mysql5.sock ) ) ) Array ( [sId] => )
              Warning: get_object_vars() expects parameter 1 to be object, boolean given in /documents/inc/class.localization.inc on line 31
              Warning: Invalid argument supplied for foreach() in /documents/inc/class.localization.inc on line 32

              Kommentar


              • #8
                Notice: Undefined index:

                diese fehlermeldung sagt aus, dass du versuchst auf ein array key zu zugreifen, der aber nicht definiert ist.

                Loesung(en):

                a) du definierst den key vorher

                PHP-Code:
                $_SESSION["sLang"] = ''
                b) du fragst ab ob der key exestiert:

                PHP-Code:
                if(isset($_SESSION['sLang'])){
                $aTplVar["aMenu"] = getMenuItems($_SERVER["PHP_SELF"], $_SESSION["sLang"], $oUser->aFunctions);

                generell setzt man vorher die variablen und uebergibt diese an die methoden weiter

                PHP-Code:
                $lang 'de';
                if(isset(
                $_SESSION['sLang'])){
                $lang $_SESSION['sLang'];
                }

                $aTplVar["aMenu"] = getMenuItems($_SERVER["PHP_SELF"],$lang$oUser->aFunctions); 

                aber dass du solche fragen stellst, sagt mir ledeglich dass dir die grundlagen fehlen
                apt-get install npm -> npm install -g bower -> bower install <package> YOLO [URL]https://www.paypal.me/BlackScorp[/URL] | Mein Youtube PHP Kanal: [url]https://www.youtube.com/c/VitalijMik[/url]

                Kommentar


                • #9
                  ja das stimmt leider - mir fehlen die Grundlagen und das ist mir auch peinlich. Ich muss das für die Arbeit machen und mir das nebenbei aneigenen. Ich studiere schon seit Wochen fleissig Bücher und Tutorials doch die Unsicherheit und das Nichtwissen nervt auch mich. Mir ist es teilweise peinlich zu fragen aber ich habe momentan keine andere Möglichkeit. Ich habe mir zig Tutorials und Bücher ausgedruckt und probiere und probiere aber ohne das es dir jemand zeigt ist es sau schwer.

                  Wie gesagt ich brauche das für die Arbeit (ich habe einen total anderen Beruf und nichts mit EDV oder Programmierung am Hut) und wir haben ein Programm bekommenwas wir nun in Eigenregie warten müssen und halt solche Fehler selbst ausmerzen müssen.

                  Zum Thema:

                  du sagtest ich soll aVar vor der foreach Schleife abfragen. Das habe ich jetzt so gemacht und festgestellt das das Array nichts enthält.
                  Die Notice ist immer noch da obwohl ich ja mit der If Schleife gesagt habe wenn die leer ist dann zeige mir die Meldung ("Die Variable $aVars ist kein Array." )an. macht PHP auch aber zusätzlich trotzdem noch die Notice

                  Notice: Undefined variable: aVars in /documents/inc/class.localization.inc on line 46
                  Die Variable $aVars ist kein Array.

                  Code:
                      function Localization ($sCountryCode, $oDatabase)
                      {
                          $this->sCountryCode = $sCountryCode;
                  
                  
                          $this->oDatabase = $oDatabase;
                          $this->oLocalizationList = new ObjectListDb($this -> oDatabase, C_LOCALIZATION_TABLE);        
                  		
                                  echo "<pre>";
                  		print_r ($this);
                  		echo "</pre>";
                          
                  		$aWhere = array ("sId" => $sCountryCode);
                  		
                  		echo "<pre>";
                  		print_r ($aWhere);
                  		echo "</pre>";
                          
                  $oLocalizationList = $this->oLocalizationList;        
                          $oLocalization = $oLocalizationList->getObject($aWhere);
                    
                  	if (is_array($aVars) == true) { 
                          
                  			$aVars = get_object_vars($oLocalization);
                  			foreach ($aVars as $sKey => $sValue)
                  			{
                  				if ($sKey == "sAdditionalFunctions")
                  				{
                  					$this -> aFunctions = array();
                  					foreach (explode (":", $sValue) as $sKey => $sFunction)
                  						$this -> aFunctions[$sFunction] = 1;
                  				}
                  				else
                  					$this -> {$sKey}=$sValue;                
                  			}            
                  
                  			if ($this->sDateFormat =="%d.%m.%Y")
                  			{
                  				$this ->iDayPos = 1;
                  				$this ->iMonthPos = 2;
                  				$this ->iYearPos = 3;            
                  			}
                  			else
                  			{
                  				$this ->iDayPos = 2;
                  				$this ->iMonthPos = 1;
                  				$this ->iYearPos = 3;            
                  			}
                  
                  		
                  	 } else {
                          echo 'Die Variable $aVars ist kein Array.';
                      }
                  }
                  Das andere Problem:
                  ich habe ja mit Print_r nun ausgegeben was die Variablen $this und $aWhere enhalten

                  echo "<pre>";
                  print_r ($this);
                  echo "</pre>";

                  echo "<pre>";
                  print_r ($aWhere);
                  echo "</pre>";
                  Als Ausgabe erhalte ich:
                  Notice: Trying to get property of non-object in /documents/hoteledit.php5 on line 38

                  Localization Object
                  (
                  [sCountryCode] =>
                  [sDateFormat] =>
                  [oDatabase] => Database Object
                  (
                  [iLink] => Resource id #32
                  [sName] => db5266XXXXX
                  [sHost] => localhost:/tmp/mysql5.sock
                  )

                  [oLocalizationList] => ObjectListDb Object
                  (
                  [sTableName] => cta_localization
                  [oDatabase] => Database Object
                  (
                  [iLink] => Resource id #32
                  [sName] => db5266XXXXX
                  [sHost] => localhost:/tmp/mysql5.sock
                  )

                  )

                  )

                  Array
                  (
                  [sId] =>
                  )


                  Notice: Undefined variable: aVars in /documents/inc/class.localization.inc on line 43
                  Die Variable $aVars ist kein Array.
                  Kannst du mir bitte kurz erklären wie man das als Anfänger lesen muß?
                  ich sehe zB das
                  [sCountryCode] =>
                  [sDateFormat] =>
                  keine Daten enhalten
                  während
                  [iLink] => Resource id #32
                  [sName] => db5266XXXXX
                  [sHost] => localhost:/tmp/mysql5.sock
                  Daten beinhalten

                  Weiterhin in der hoteledit.php5 ist folgender Abschnitt

                  // user
                  $oUser = new User($oDatabase);
                  $oUser ->loadBySId($_SESSION["sUsername"]);
                  $sLangUser = $oUser -> sLanguageCode;
                  $oUserCountry = new Country ($oDatabase);
                  $oUserCountry -> load($oUser -> iCountryId);


                  heisst dort werden doch die Language und Country geholt und diese Spalten in der DB gibt es auch
                  Müßten diese Werte dann nicht in der funktion übergeben werden?
                  $aWhere = array ("sId" => $sCountryCode);

                  Kommentar


                  • #10
                    PHP-Code:
                    if (is_array($aVars) == true) { 
                            
                                
                    $aVars get_object_vars($oLocalization);
                                foreach (
                    $aVars as $sKey => $sValue
                    das ist aber nicht vor der foreach

                    PHP-Code:
                            
                                $aVars 
                    get_object_vars($oLocalization);
                    if (
                    is_array($aVars) == true) { 

                                foreach (
                    $aVars as $sKey => $sValue
                    das waere vor foreach

                    [sCountryCode] =>
                    [sDateFormat] =>
                    das koennte aber auch bedeuten dass da true oder false oder null drin steht, verwende statt print_r lieber var_dump

                    zu dem $sCountryCode der kommt aus dem parameter
                    PHP-Code:
                     function Localization ($sCountryCode$oDatabase
                    d.h. irgendwo an einer anderen stelle wird $oLocalization = new Localization($countryCode,$dataBase) aufgerufen
                    apt-get install npm -> npm install -g bower -> bower install <package> YOLO [URL]https://www.paypal.me/BlackScorp[/URL] | Mein Youtube PHP Kanal: [url]https://www.youtube.com/c/VitalijMik[/url]

                    Kommentar


                    • #11
                      Hallo danke für deine Antwort

                      wenn ich die IF Abfrage eine Zeile runter setzte bekomme ich einen neuen Fehler und die kann ich absolut nicht deuten
                      Warning: get_object_vars() expects parameter 1 to be object, boolean given in /documents/inc/class.localization.inc on line 47
                      das wäre diese zeile: $aVars = get_object_vars($oLocalization);
                      deshalb hatte ich sie eines weiter hoch gesetzt

                      Thema print_r und var_dump

                      ich habe alle prints durch var_dump ersetzt und bekomme jetzt das hier: (siehe unten)
                      heisst es kommt NULL an
                      wie wäre jetzt meine Vorgehensweise um diesen Fehler zu vermeiden. Interessanterweise habe ich noch eine Entdeckung gemacht. Im Reiter davor CITY MANAGEMENT (also oben in diesen Programm ist ja Menü) dort wird eine Liste aller Hotels aller Länder angezeigt. Wenn ich dort auf ein Land/Stadt gehe und die Liste dort aufklappe (die ist standartmässig zugeklappt) und dann oben auf den Reiter gehe wo ich die Hotels editieren kann (hoteledit.pghp5) dann werden Werte übergeben!! Dann steht da BE oder DE je nachdem welches land ich vorher aufgeklappt habe.

                      Notice: Trying to get property of non-object in /documents/hoteledit.php5 on line 38

                      NULL

                      object(Database)#5 (3) {
                      ["iLink"]=>
                      resource(32) of type (mysql link persistent)
                      ["sName"]=>
                      string(11) "db52664XXXX"
                      ["sHost"]=>
                      string(26) "localhost:/tmp/mysql5.sock"
                      }

                      object(Localization)#27 (4) {
                      ["sCountryCode"]=>
                      NULL
                      ["sDateFormat"]=>
                      NULL
                      ["oDatabase"]=>
                      object(Database)#5 (3) {
                      ["iLink"]=>
                      resource(32) of type (mysql link persistent)
                      ["sName"]=>
                      string(11) "db5266XXXXXX"
                      ["sHost"]=>
                      string(26) "localhost:/tmp/mysql5.sock"
                      }
                      ["oLocalizationList"]=>
                      object(ObjectListDb)#26 (2) {
                      ["sTableName"]=>
                      string(16) "cta_localization"
                      ["oDatabase"]=>
                      object(Database)#5 (3) {
                      ["iLink"]=>
                      resource(32) of type (mysql link persistent)
                      ["sName"]=>
                      string(11) "db5266XXXXX"
                      ["sHost"]=>
                      string(26) "localhost:/tmp/mysql5.sock"
                      }
                      }
                      }

                      array(1) {
                      ["sId"]=>
                      NULL
                      }


                      Warning: get_object_vars() expects parameter 1 to be object, boolean given in /documents/inc/class.localization.inc on line 47
                      Die Variable $aVars ist kein Array.
                      und das kommt wenn ich vorher was in vorhergehenden reiter aufklappe

                      string(2) "de"

                      object(Database)#5 (3) {
                      ["iLink"]=>
                      resource(32) of type (mysql link persistent)
                      ["sName"]=>
                      string(11) "db5266xxxxxx"
                      ["sHost"]=>
                      string(26) "localhost:/tmp/mysql5.sock"
                      }

                      object(Localization)#26 (4) {
                      ["sCountryCode"]=>
                      string(2) "de"
                      ["sDateFormat"]=>
                      NULL
                      ["oDatabase"]=>
                      object(Database)#5 (3) {
                      ["iLink"]=>
                      resource(32) of type (mysql link persistent)
                      ["sName"]=>
                      string(11) "db5266xxxxx"
                      ["sHost"]=>
                      string(26) "localhost:/tmp/mysql5.sock"
                      }
                      ["oLocalizationList"]=>
                      object(ObjectListDb)#25 (2) {
                      ["sTableName"]=>
                      string(16) "cta_localization"
                      ["oDatabase"]=>
                      object(Database)#5 (3) {
                      ["iLink"]=>
                      resource(32) of type (mysql link persistent)
                      ["sName"]=>
                      string(11) "db5266xxxxxx"
                      ["sHost"]=>
                      string(26) "localhost:/tmp/mysql5.sock"
                      }
                      }
                      }

                      array(1) {
                      ["sId"]=>
                      string(2) "de"
                      }

                      Kommentar


                      • #12
                        Warning: get_object_vars() expects parameter 1 to be object, boolean given in /documents/inc/class.localization.inc on line 47
                        das wäre diese zeile: $aVars = get_object_vars($oLocalization)
                        Da steht, das du an get_object_vars() kein Objekt übergibst sondern ein boolean .. dh dein $oLocalization Objekt ist keines, sondern true oder false. Prüf das mal und den Grund dafür, ev. geht vorher schon was schief und daher ist es false.. beispielsweise.

                        http://www.php.de/php-einsteiger/543...produkten.html
                        The string "()()" is not palindrom but the String "())(" is.

                        Debugging: Finde DEINE Fehler selbst! | Gegen Probleme beim E-Mail-Versand | Sicheres Passwort-Hashing | Includes niemals ohne __DIR__
                        PHP.de Wissenssammlung | Kein Support per PN

                        Kommentar


                        • #13
                          es bringt hier nichts weiter zu machen, du sagtest dass ihr den script gekauft habt? wendet euch doch dann bitte an den entwickler, ich wette da ist einfach eine fehlende spracheinstellung die in irgend einer includierten datei steht die ihr nicht eingebunden habt
                          apt-get install npm -> npm install -g bower -> bower install <package> YOLO [URL]https://www.paypal.me/BlackScorp[/URL] | Mein Youtube PHP Kanal: [url]https://www.youtube.com/c/VitalijMik[/url]

                          Kommentar


                          • #14
                            schade - ich kann mich leider nicht mehr an den Entwickler wenden da er es so abgegeben hat wie es ist - er macht nichts mehr dran - so wurde das vereinbart.
                            Ich weiss ist nicht richtig aber ich bin kein Entscheidungsträger. Es sind ja nur Warnungen - wenn ich die Fehleranzeige wieder ausschalte sieht das auch keiner - es läuft ja im grunde alles mehr oder minder - ich wollte halt zu perfekt sein.

                            Nun ja dann muss ich weiter durchwurschteln

                            Kommentar


                            • #15
                              Kannst ja hier posten, ev. hat jemand Zeit und Lust zum fixen: http://www.php.de/scriptboerse/
                              The string "()()" is not palindrom but the String "())(" is.

                              Debugging: Finde DEINE Fehler selbst! | Gegen Probleme beim E-Mail-Versand | Sicheres Passwort-Hashing | Includes niemals ohne __DIR__
                              PHP.de Wissenssammlung | Kein Support per PN

                              Kommentar

                              Lädt...
                              X