LS,

Met deze regel controleer ik of in de URL de variable report gevult is.

<?php

$report = ( isset ( $_GET["report"] ) && trim ( $_GET["report"] ) != '' ) ? trim ( $_GET["report"] ) : 'default';
?>

als GET[report] niet gevuld is krijgt $report de waarde default.

Is het mogelijk om als report niet in de URL voorkomt $report de waarde "EMPTY" te geven??

Harry
De include staat voor de function en in de function wil jij $report gebruiken.
Voor de function zal $report bekend zijn, maar in de function niet.
Laat eens de gehele class zien.
Ik denk dat je daarvoor geen include nodig hebt maar dat het makkelijk in de class zelf kan.
Maar ik weet niet hoe die class er verder uitziet.
Sorry, maar nu ik ben ik de weg weer kwijt. Ik heb het over een variable UIT een include naar een functie waar de variabele $_GET['report'] wel werkt. Ik heb het niet over een class dus??

Waar plaats ik in een script dan global $report
<?php
function Header() {
global $report;
// Logo
// Set color
.......
?>
Ik denk dat het probleem ook in TCPDF gezocht moet worden, want ik krijg nu de foutmelding

Warning: Cannot modify header information - headers already sent by (output started at /home/harry-arends.nl/public_html/event/gearboxTCPDF.php:57) maar ik stuur niets
dit is nu mijn code:

<?p[hp
// if no active session we start a new one
if (session_id() == "") session_start(); 
ini_set("memory_limit","80M");
// Remove this in production, for debug only
ini_set("error_reporting", E_ALL);

include("datacon.php");
include("include/functions.php");
// tcpdf are in the websites root directory 
require_once('../tcpdf/config/lang/eng.php');
require_once('../tcpdf/tcpdf.php');

include ("gearboxTCPDF.php");
// Extend the TCPDF class to create custom Header and Footer
class MYPDF extends TCPDF {

	//Page header
	function Header() {
		global $report;
		// Logo
		// Set color
        $this->SetTextColor(0, 0, 0);
		// Set font
		$this->SetFont('helvetica', 'B', 34);
		// Title
		$this->Cell(0, 0, $report, 0, false, 'C', 0, 'L', 0, false, 'M', 'M');
		$image_file = 'images/Header_Brief.png';
		$this->Image($image_file, 0, 6, 210, '', 'PNG', '', 'T', false, 300, '', false, false, 0, false, false, false);
	}
?>


de inhoud van de include file(gearboxTCPDF.php is als volgt:

<?php
//============================================================+
// File name   : gearboxTCPDF.php 
// Begin       : 2017-07-15
// Last Update : 2017-07-15
// called from : printTCPDF.php
//
// Description : This script acts like a gearbox, controlling 
//               witch report should be printed. 
//
// Author: Harry H. Arends
//
//(c) Copyright: 2017
//               Harry H. Arends
//               7521VG13 Enschede
//               www.military-boekelo.nl
//               [email protected]
//============================================================+
//From the URL the report name is passed on
//Depending on it some variables sre set and a template is included
// ---------------------------------------------------------
// URL can look like printTCPDF?report=name
//							   &label=Yes/No
//							   &horseFEIid=1234567
//							   &type=rider/groom/horse 
// ---------------------------------------------------------
//The following report are possible
/* URL like printTCPDF.php?report=name
 *** reportname ******** description *************************
 * accomodation        requested accomodation rider & groom  *
 * all-entries         simple listing of all entrie entered  *
 * bedding             list horses on straw/schavings        *
 * caravan             list grooms in caravan with number    *
 * checkCastrated      check and list all geding             *
 * entriescompetition  print all entries in competition      *
 * entriesWaitingList  print combinations on the waitinglist *
 * FEIcheck            contains Rider/Horse FEIid            */
/* URL like printTCPDF.php?report=name&FEIid=123456789
 *** reportname ******** description *************************
 * EntrieSingle        Print single combination              */
// ---------------------------------------------------------
//First check for a report-name
$report = ( isset ( $_GET["report"] ) ) ? trim ( $_GET["report"] ) : 'EMPTY';
$report = ( $report == '' ) ? 'default' : $report;
// Then create the template name for further use
$template = "/template.TCPDF.".$report.".php";
$html = $template."<br />";
//Check if template file exitst
if(!(file_exists(dirname(__FILE__)."/".$template))) {
        $html .= "  The template file does not exist<br />";
}
//$html .= "Template  file : ".dirname(__FILE__)."/".$template."<br />";
//$html .= realpath(dirname(__FILE__))."<br />";
//$html .= dirname(__FILE__)."<br />";
?>

heb ook nog gekeken of ik ergens een print of echo opdracht heb staan maar nee want daarlijkt deze fout.
Indie nodig kan ik hethoofd script ook posten.

Harry


[size=xsmall]Toevoeging op 16/07/2017 20:00:23:[/size]

Harry H Arends op 16/07/2017 10:30:48

@Ward, sorry ik was dit in een los script aan het testen, buiten het grote script om, en was dus vergeten om error melding daarin te plaatsen. Dat automatischme is er nog niet.

@Ben Rob bedoeldt het goed maar je hebt wel gelijk men moet niet teveel dingen er bij halen.
De routine ziet er nu zo uit, kan misschien wel anders opgebouwdt worden.

<?php
//First check for a report-name
$report = ( isset ( $_GET["report"] ) ) ? trim ( $_GET["report"] ) : 'EMPTY';
$report = ( $report == '' ) ? 'default' : $report;
// Then create the template name for further use
$template = "/template.TCPDF.".$report.".php";
echo $template."<br />";
//Check if template file exitst
if(!(file_exists(dirname(__FILE__)."/".$template))) {
        echo "The template file does not exist<br />";
}
echo "Template  file : ".dirname(__FILE__)."/".$template."<br />";
echo realpath(dirname(__FILE__))."<br />";
echo dirname(__FILE__)."<br />";
?>



[size=xsmall]Toevoeging op 16/07/2017 11:21:51:[/size]

Nu heb ik bovenstaand script als een include in mijn hoofd script geplaatst en krijg dan de melding dat de variable op regel niet aanwezig is.

<?php
include ("gearboxTCPDF.php");
// Extend the TCPDF class to create custom Header and Footer
class MYPDF extends TCPDF {

	//Page header
	function Header() {
		// Logo
		// Set color
        $this->SetTextColor(0, 0, 0);
		// Set font
		$this->SetFont('helvetica', 'B', 34);
		// Title
		$this->Cell(0, 0, $report, 0, false, 'C', 0, 'L', 0, false, 'M', 'M');
		$image_file = 'images/Header_Brief.png';
		$this->Image($image_file, 0, 6, 210, '', 'PNG', '', 'T', false, 300, '', false, false, 0, false, false, false);
	}
?>


[size=xsmall]Toevoeging op 16/07/2017 11:24:55:[/size]

[quote="Harry H Arends op 16/07/2017 10:30:48"]
@Ward, sorry ik was dit in een los script aan het testen, buiten het grote script om, en was dus vergeten om error melding daarin te plaatsen. Dat automatischme is er nog niet.

@Ben Rob bedoeldt het goed maar je hebt wel gelijk men moet niet teveel dingen er bij halen.
De routine ziet er nu zo uit, kan misschien wel anders opgebouwdt worden.

<?php
//First check for a report-name
$report = ( isset ( $_GET["report"] ) ) ? trim ( $_GET["report"] ) : 'EMPTY';
$report = ( $report == '' ) ? 'default' : $report;
// Then create the template name for further use
$template = "/template.TCPDF.".$report.".php";
echo $template."<br />";
//Check if template file exitst
if(!(file_exists(dirname(__FILE__)."/".$template))) {
        echo "The template file does not exist<br />";
}
echo "Template  file : ".dirname(__FILE__)."/".$template."<br />";
echo realpath(dirname(__FILE__))."<br />";
echo dirname(__FILE__)."<br />";
?>



[size=xsmall]Toevoeging op 16/07/2017 11:21:51:[/size]

Nu heb ik bovenstaand script als een include in mijn hoofd script geplaatst en krijg dan de melding dat de variable op regel 14 niet aanwezig is. Hier stond eerst gewoon $_GET['report'] en dat werkte wel.

<?php
include ("gearboxTCPDF.php");
// Extend the TCPDF class to create custom Header and Footer
class MYPDF extends TCPDF {

	//Page header
	function Header() {
		// Logo
		// Set color
        $this->SetTextColor(0, 0, 0);
		// Set font
		$this->SetFont('helvetica', 'B', 34);
		// Title
		$this->Cell(0, 0, $report, 0, false, 'C', 0, 'L', 0, false, 'M', 'M');
		$image_file = 'images/Header_Brief.png';
		$this->Image($image_file, 0, 6, 210, '', 'PNG', '', 'T', false, 300, '', false, false, 0, false, false, false);
	}
?>

Moet ik iets speciaal doen om variabelen uit een include door te sturen??



[/quote]

=====================================================
Om toch verder te kunnen heb ik de regels met code uit de include gekopieerd naat de hoofd script en nu werkt het wel. toch wel vreemd.
bedankt voor alle input, Harry

Reageren