Ergebnis 1 bis 5 von 5

Thema: PHP Datei in Contao aufrufen

  1. #1
    Contao-Fan
    Registriert seit
    13.12.2012.
    Beiträge
    621

    Standard PHP Datei in Contao aufrufen

    Hi,

    ich möchte in einem HTML Inhaltselement eine PHP Datei aufrufen: {{file::training-courses-de.php}}

    Das klappt aber ich bekomme folgenden Fehler:
    Code:
    [2018-03-08 18:22:23] request.INFO: Matched route "contao_frontend". {"route":"contao_frontend","route_parameters":{"_token_check":true,"_controller":"Contao\\CoreBundle\\Controller\\FrontendController::indexAction","_scope":"frontend","_locale":null,"alias":"training-kursdetails","_route":"contao_frontend"},"request_uri":"http://dev.intra.de/training-kursdetails?course=ICM-010","method":"HEAD"} []
    [2018-03-08 18:22:23] security.INFO: Attempting SimplePreAuthentication. {"key":"frontend","authenticator":"Contao\\CoreBundle\\Security\\ContaoAuthenticator"} []
    [2018-03-08 18:22:23] request.INFO: Matched route "contao_frontend". {"route":"contao_frontend","route_parameters":{"_token_check":true,"_controller":"Contao\\CoreBundle\\Controller\\FrontendController::indexAction","_scope":"frontend","_locale":null,"alias":"training-kursdetails","_route":"contao_frontend"},"request_uri":"http://dev.intra.de/training-kursdetails?course=ICM-010","method":"GET"} []
    [2018-03-08 18:22:23] security.INFO: Attempting SimplePreAuthentication. {"key":"frontend","authenticator":"Contao\\CoreBundle\\Security\\ContaoAuthenticator"} []
    [2018-03-08 18:22:23] app.CRITICAL: An exception occurred. {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Cannot use string offset as an array at /wwwroot.wwwnew/templates/training-courses-de.php:51)"} []
    In Zeile 51 steht folgende:
    Code:
    $list{$count}{'id'}=$row['Id'];
    Im ganzen:
    Code:
    if($result->numRows) {
    		$rows = $result->fetchAllAssoc();
    		$count=0;
    		foreach ($rows as $row) {
    			$count++;
    			$list{$count}{'id'}=$row['Id'];
    			$list{$count}{'name'}=$row['NAME'];
    			$list{$count}{'start'}=substr($row['START_DT'],8,2).'.'.substr($row['START_DT'],5,2).'.'.substr($row['START_DT'],0,4);
    			$list{$count}{'end'}=$row['END_DT'];
    			$list{$count}{'descr'}=$row['DESC_TEXT'];
    			$list{$count}{'location'}=$row['LOCATION_DESC'];
    			$list{$count}{'status'}=$row['STATUS_CD'];
    			$list{$count}{'duration'}=$row['DURATION_DESC'];
    			$list{$count}{'currency'}=$row['LST_PRI_CURCY_CD'];
    			$list{$count}{'price'}=$row['LST_PRI_AMT'];
    		}
    		$list[0]=$count;
    Was mache ich da?

    LG & Danke

  2. #2
    Wandelndes Contao-Lexikon Avatar von tab
    Registriert seit
    22.10.2013.
    Beiträge
    10.078
    Contao-Projekt unterstützen

    Support Contao

    Standard

    Irgendeine deiner Variablen wird als String initialisert und als Array verwendet, was nicht geht. Eventuekk mal versuchen, die Variable $list zuerst zu initialiseren als
    PHP-Code:
    $list = array(); 

  3. #3
    Contao-Fan
    Registriert seit
    13.12.2012.
    Beiträge
    621

    Standard

    Danke, dass hat geklappt aber jetzt bekomme ich diese warnung:

    Code:
    Warning: Illegal string offset 'id' in /wwwroot.wwwnew/templates/training-courses-de.php on line 125
    Warning: Illegal string offset 'name' in /wwwroot.wwwnew/templates/training-courses-de.php on line 126
    Warning: Illegal string offset 'start' in /wwwroot.wwwnew/templates/training-courses-de.php on line 127
    Warning: Illegal string offset 'end' in /wwwroot.wwwnew/templates/training-courses-de.php on line 128
    Warning: Illegal string offset 'descr' in /wwwroot.wwwnew/templates/training-courses-de.php on line 129
    Warning: Illegal string offset 'location' in /wwwroot.wwwnew/templates/training-courses-de.php on line 130
    Warning: Illegal string offset 'status' in /wwwroot.wwwnew/templates/training-courses-de.php on line 131
    Warning: Illegal string offset 'duration' in /wwwroot.wwwnew/templates/training-courses-de.php on line 132
    Warning: Illegal string offset 'currency' in /wwwroot.wwwnew/templates/training-courses-de.php on line 133
    Warning: Illegal string offset 'price' in /wwwroot.wwwnew/templates/training-courses-de.php on line 134
    Warning: Illegal string offset 'descr' in /wwwroot.wwwnew/templates/training-courses-de.php on line 137
    Warning: Illegal string offset 'name' in /wwwroot.wwwnew/templates/training-courses-de.php on line 137
    Warning: Illegal string offset 'location' in /wwwroot.wwwnew/templates/training-courses-de.php on line 138
    
    Warning: Illegal string offset 'start' in /wwwroot.wwwnew/templates/training-courses-de.php on line 139
    
    Warning: Illegal string offset 'duration' in /wwwroot.wwwnew/templates/training-courses-de.php on line 139
    
    Warning: Illegal string offset 'name' in /wwwroot.wwwnew/templates/training-courses-de.php on line 140
    Das wären diese Zeilen:
    Code:
    $list{'id'}=$row['Id'];
    		$list{'name'}=$row['NAME'];
    		$list{'start'}=substr($row['START_DT'],8,2).'.'.substr($row['START_DT'],5,2).'.'.substr($row['START_DT'],0,4);
    		$list{'end'}=$row['END_DT'];
    		$list{'descr'}=$row['DESC_TEXT'];
    		$list{'location'}=$row['LOCATION_DESC'];
    		$list{'status'}=$row['STATUS_CD'];
    		$list{'duration'}=$row['DURATION_DESC'];
    		$list{'currency'}=$row['LST_PRI_CURCY_CD'];
    		$list{'price'}=$row['LST_PRI_AMT'];
    Dort auch wieder das mit dem Array?

  4. #4
    Wandelndes Contao-Lexikon Avatar von tab
    Registriert seit
    22.10.2013.
    Beiträge
    10.078
    Contao-Projekt unterstützen

    Support Contao

    Standard

    Würde ich probieren, ja.

  5. #5
    Contao-Fan
    Registriert seit
    13.12.2012.
    Beiträge
    621

    Standard

    Hat geklappt, Danke

Aktive Benutzer

Aktive Benutzer

Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)

Lesezeichen

Lesezeichen

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •