Home » RADICORE development » Transaction Patterns » Error running output2 pattern
Error running output2 pattern [message #4287] |
Tue, 24 June 2014 11:47 |
htManager
Messages: 433 Registered: May 2014
|
Senior Member |
|
|
Hi,
the following error message comes up when running an output2 pattern:
2014-06-24 17:34:15
Fatal Error: Some data has already been output, can't send PDF file (# 256)
Error in line 559 of file '/var/www/vhosts/mgh-saar.de/includes/std.pdf.class.inc'.
PHP_SELF: /htmanager/htm/htm_db_kontakte(output2).php
CURRENT DIRECTORY: /var/www/vhosts/mgh-saar.de/htm/htmanager/htm
SERVER_ADDR: 217.91.254.197
SERVER_NAME: www.htmanager.de
HTTP_HOST: www.htmanager.de
User Id: TVN
Role Id: GLOBAL
REMOTE_ADDR: 217.91.254.197
REQUEST_URI: /htmanager/htm/htm_db_kontakte(output2).php?session_name=men u0
Page Stack:
[0] main_menu
[1] htm
[2] htm_db_kontakte(list1)
[3] htm_db_kontakte(output2)
Backtrace:
0: array =
function: string = errorHandler
args: array =
0: integer = 256
1: string = Some data has already been output, can't send PDF file
2: string = /var/www/vhosts/mgh-saar.de/includes/std.pdf.class.inc
3: integer = 559
4: array =
msg: string = Some data has already been output, can't send PDF file
1: array =
file: string = /var/www/vhosts/mgh-saar.de/includes/std.pdf.class.inc
line: integer = 559
function: string = trigger_error
args: array =
0: string = Some data has already been output, can't send PDF file
1: integer = 256
2: array =
file: string = /var/www/vhosts/mgh-saar.de/includes/tcpdf/tcpdf_php5.php
line: integer = 7586
function: string = Error
class: string = PDF
type: string = ->
args: array =
0: string = Some data has already been output, can't send PDF file
3: array =
file: string = /var/www/vhosts/mgh-saar.de/includes/std.pdf.class.inc
line: integer = 1679
function: string = Output
class: string = TCPDF
type: string = ->
args: array =
0: string = htm_db_kontakte.pdf
1: string = I
4: array =
file: string = /var/www/vhosts/mgh-saar.de/includes/std.output2.inc
line: integer = 92
function: string = outputPDF_ListView
class: string = PDF
type: string = ->
args: array =
5: array =
file: string = /var/www/vhosts/mgh-saar.de/htm/htmanager/htm/htm_db_kontakt e(output2).php
line: integer = 18
args: array =
0: string = /var/www/vhosts/mgh-saar.de/includes/std.output2.inc
function: string = require
Changing destination from 'I' to 'D' brings up the same error.
What did I wrong?
|
|
|
Re: Error running output2 pattern [message #4324 is a reply to message #4287] |
Sun, 06 July 2014 04:38 |
AJM
Messages: 2367 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
None of my OUTPUT2 tasks fail in this way, so there must be something wrong in your code. This type of error is caused by something being output, which could be a single blank line, before the script tries to produce its own output. I suggest you take a look at your scripts to see if there are any blank lines either before the opening "<?php" or after the closing "?>".
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
Re: Error running output2 pattern [message #4339 is a reply to message #4324] |
Fri, 11 July 2014 10:10 |
htManager
Messages: 433 Registered: May 2014
|
Senior Member |
|
|
Sorry for replying once more but I checked the scripts if there are blank lines before or after the php-tag but there aren't.
I also checked if I can open the list views of the framework. I can open them.
I deleted an recreated the output-tasks. The same result.
I created all the possible output-tasks (1 to 5). Everything works fine but the list view and the label view.
I also checked the table schema with relations etc. with no success.
I removed the column 'rdcaccount_id' and the relation to the mnu_account table. The same result.
I traced the code to the function output($name, $dest) in the file tcpdf_php5.php where the error is probably(?) generated. But I am not familiar enough to see what is going wrong.
What else could be wrong? Do I have to take care of certain table restrictions or something like that? I attached the file kontakte.dict.inc.
[Updated on: Fri, 11 July 2014 10:12] Report message to a moderator
|
|
|
Re: Error running output2 pattern [message #4340 is a reply to message #4339] |
Fri, 11 July 2014 11:52 |
AJM
Messages: 2367 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
There is no attachment, so I cannot examine your script.
Blank lines before or after the PHP tags are just one way of causing this error. Another would be to have an echo statement somewhere which writes to the output stream.
I do not have this error with any of the OUTPUT2 tasks that I have generated, so it is not caused by my code. You need to examine your scripts very carefully to see where it is writing to the output stream.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
Re: Error running output2 pattern [message #4341 is a reply to message #4340] |
Sat, 12 July 2014 02:18 |
htManager
Messages: 433 Registered: May 2014
|
Senior Member |
|
|
All the code is automatically generated by the Frameword, that's why I don't understand that it doesn't work.
Here is the code of the task script: htm_kontakte(output2).php:
<?php
//********************************************************** *******************
// Extract the contents of a database table and export them to a PDF file which
// will be downloaded to the client device.
//********************************************************** *******************
$table_id = 'kontakte'; // table name
$report = 'kontakte.list.report.inc'; // file identifying report structure
// customise the SQL SELECT statement
$sql_select = null;
$sql_from = null;
$sql_where = null;
$sql_groupby = null;
$sql_having = null;
$sql_orderby = null;
require 'std.output2.inc'; // activate page controller
?>
Here is the code of the class file:
<?php
// ************************************************************ *****************
// Copyright 2003-2005 by A J Marston <http://www.tonymarston.net>
// Copyright 2006-2012 by Radicore Software Limited <http://www.radicore.org>
// ************************************************************ *****************
require_once 'std.table.class.inc';
class kontakte extends Default_Table
{
// ************************************************************ ****************
function kontakte ()
{
// save directory name of current script
$this->dirname = dirname(__file__);
$this->dbms_engine = ''; // to be supplied by getFieldSpec_original()
$this->dbprefix = ''; // to be supplied by getFieldSpec_original()
$this->dbname = 'htm';
$this->tablename = 'kontakte';
// call this method to get original field specifications
// (note that they may be modified at runtime)
$this->fieldspec = $this->getFieldSpec_original();
} // kontakte
function _cm_getInitialData ($fieldarray)
// Perform custom processing for the getInitialData method.
// $fieldarray contains data from the initial $where clause.
{
// $_SESSION['logon_user_id'] = $logon_user_id;
// $_SESSION['logon_user_name'] = $fieldarray['user_name'];
// $_SESSION['role_id'] = $fieldarray['role_id'];
// $_SESSION['logon_email_addr'] = $fieldarray['email_addr'];
// $_SESSION['rdcaccount_id'] = $fieldarray['rdcaccount_id'];
if (!empty($_SESSION['logon_user_id'])) {
// get next available number for user_seq_no
$where = "user_id='{$_SESSION['logon_user_id']}'";
$query = "SELECT max(user_seq_no) FROM $this->tablename WHERE $where";
$count = $this->getCount($query);
$fieldarray['user_id'] = $_SESSION['logon_user_id'];
$fieldarray['user_seq_no'] = $count + 1;
} // if
// set these fields to 'noedit' (read only)
$this->fieldspec['user_id']['noedit'] = 'y';
$this->fieldspec['user_seq_no']['noedit'] = 'y';
return $fieldarray;
} // _cm_getInitialData
function _cm_getExtraData ($where, $fieldarray)
// Perform custom processing for the getExtraData method.
// $where = a string in SQL 'where' format.
// $fieldarray = the contents of $where as an array.
{
// get values for kontakt_typ_id and insert into lookup array
$array = $this->getValRep('kontakt_typ_id');
$this->lookup_data['kontakt_typ_id'] = $array;
// get values for kontakt_position_id and insert into lookup array
$array = $this->getValRep('kontakt_position_id'); // Feld in Tabelle kontakte
$this->lookup_data['kontakt_position_id'] = $array; // s.o.
// get contents of foreign table KONTAKTE_TYP and add to lookup array
$dbobject =& RDCsingleton::getInstance('kontakte_typ');
$array = $dbobject->getValRep('kontakt_typ_id_list');
$this->lookup_data['kontakt_typ_id_list'] = $array;
// get contents of foreign table KONTAKTE_POSITION and add to lookup array
$dbobject =& RDCsingleton::getInstance('kontakte_position'); // Lookup-Tabelle
$array = $dbobject->getValRep('kontakt_position_id'); // Lookup-Tabellen-Feld
$this->lookup_data['kontakt_position_id'] = $array;
return $fieldarray;
} // _cm_getExtraData
// ************************************************************ ****************
} // end class
// ************************************************************ **************** <?php
// file created on July 11, 2014, 3:31 pm
// field specifications for table htm.kontakte
$fieldspec['user_id'] = array('type' => 'string',
'size' => 16,
'pkey' => 'y',
'required' => 'y',
'uppercase' => 'y');
$fieldspec['user_seq_no'] = array('type' => 'integer',
'type_native' => 'int',
'size' => 11,
'minvalue' => 0,
'maxvalue' => 4294967295,
'pkey' => 'y',
'required' => 'y');
$fieldspec['rdcaccount_id'] = array('type' => 'integer',
'type_native' => 'int',
'size' => 10,
'minvalue' => 0,
'maxvalue' => 4294967295,
'required' => 'y',
'default' => '1');
$fieldspec['kontakt_typ_id'] = array('type' => 'string',
'size' => 6,
'required' => 'y',
'default' => 'SP',
'uppercase' => 'y',
'control' => 'dropdown',
'optionlist' => 'kontakt_typ_id_list');
$fieldspec['node_id'] = array('type' => 'integer',
'type_native' => 'int',
'size' => 5,
'minvalue' => 0,
'maxvalue' => 4294967295,
'default' => '0');
$fieldspec['kontakt_name'] = array('type' => 'string',
'size' => 50,
'required' => 'y');
$fieldspec['kontakt_vorname'] = array('type' => 'string',
'size' => 50);
$fieldspec['kontakt_strasse'] = array('type' => 'string',
'size' => 100);
$fieldspec['kontakt_lkz'] = array('type' => 'string',
'size' => 10);
$fieldspec['kontakt_plz'] = array('type' => 'string',
'size' => 10);
$fieldspec['kontakt_ort'] = array('type' => 'string',
'size' => 50);
$fieldspec['kontakt_telefon_privat'] = array('type' => 'string',
'size' => 30);
$fieldspec['kontakt_telefon_arbeit'] = array('type' => 'string',
'size' => 30);
$fieldspec['kontakt_telefon_mobil'] = array('type' => 'string',
'size' => 30);
$fieldspec['kontakt_email'] = array('type' => 'string',
'size' => 50);
$fieldspec['kontakt_fax'] = array('type' => 'string',
'size' => 50);
$fieldspec['kontakt_geburtstag'] = array('type' => 'date',
'size' => 12);
$fieldspec['kontakt_wurfhand'] = array('type' => 'string',
'size' => 2,
'default' => 'R');
$fieldspec['kontakt_position_id'] = array('type' => 'string',
'size' => 6,
'control' => 'dropdown',
'optionlist' => 'kkontakt_position_id');
$fieldspec['created_date'] = array('type' => 'datetime',
'size' => 20,
'required' => 'y',
'default' => '2014-01-01 00:00:00',
'autoinsert' => 'y',
'noedit' => 'y',
'nosearch' => 'y');
$fieldspec['created_user'] = array('type' => 'string',
'size' => 16,
'required' => 'y',
'autoinsert' => 'y',
'noedit' => 'y',
'nosearch' => 'y');
$fieldspec['revised_date'] = array('type' => 'datetime',
'size' => 20,
'autoupdate' => 'y',
'noedit' => 'y',
'nosearch' => 'y');
$fieldspec['revised_user'] = array('type' => 'string',
'size' => 16,
'autoupdate' => 'y',
'noedit' => 'y',
'nosearch' => 'y');
// primary key details
$this->primary_key = array('user_id',
'user_seq_no');
// unique key details
$this->unique_keys = array();
// child relationship details
$this->child_relations[] = array('child' => 'kontakte_ausruestung',
'type' => 'RES',
'fields' => array('user_id' => 'user_id',
'user_seq_no' => 'user_seq_no'));
$this->child_relations[] = array('child' => 'mannschaften_kontakte',
'type' => 'RES',
'fields' => array('user_id' => 'kontakt_ma_user_id',
'user_seq_no' => 'kontakt_ma_user_seq_no'));
$this->child_relations[] = array('child' => 'spiele_transport',
'type' => 'RES',
'fields' => array('user_id' => 'transport_user_id',
'user_seq_no' => 'transport_user_seq_no'));
$this->child_relations[] = array('child' => 'spiele_transport_mitfahrer',
'type' => 'RES',
'fields' => array('user_id' => 'mitfahrer_user_id',
'user_seq_no' => 'mitfahrer_user_seq_no'));
// parent relationship details
$this->parent_relations[] = array('parent' => 'kontakte_position',
'fields' => array('kontakt_position_id' => 'kontakt_position_id',
'rdcaccount_id' => 'rdcaccount_id'));
$this->parent_relations[] = array('parent' => 'kontakte_typ',
'fields' => array('kontakt_typ_id' => 'kontakt_typ_id',
'rdcaccount_id' => 'rdcaccount_id'));
$this->parent_relations[] = array('parent' => 'mnu_account',
'dbname' => 'menu',
'subsys_dir' => 'menu',
'fields' => array('rdcaccount_id' => 'rdcaccount_id'));
// determines if database updates are recorded in an audit log
$this->audit_logging = TRUE;
// default sort sequence
$this->default_orderby = '';
// alternative language options
$this->alt_language_table = '';
$this->alt_language_cols = '';
// alias names
$this->nameof_start_date = '';
$this->nameof_end_date = '';
// finished
?><?php
// report structure for a LIST view
$structure['pdf'] = array('orientation' => 'L', // L=Landscape, P=Portrait
'units' => 'mm', // pt=Point, mm=Millimeter, cm=Centimeter, in=Inch
'format' => 'A4', // A3, A4, A5, Letter, Legal
'name' => '', // filename (if destination = D or F)
'destination' => 'I'); // I=Inline (browser), D=Download (browser), F=Filename (on server), S=String
$structure['title']['style'] = 'title'; // style for page title
$structure['head']['style'] = 'hdg'; // style for column headings
$structure['body']['style'] = 'body'; // style for main body
$structure['foot']['style'] = 'foot'; // style for page footer
// define contents of page title
$structure['title'][] = array('text' => '- Kontakte -',
'width' => 100,
'align' => 'center',
'border' => 'y');
// set column widths
$structure['columns'][] = array('width' => '20', 'overflow' => 'y'); // Name
$structure['columns'][] = array('width' => '20', 'overflow' => 'y'); // Vorname
$structure['columns'][] = array('width' => '20', 'overflow' => 'y'); // Strasse
$structure['columns'][] = array('width' => '10', 'overflow' => 'y'); // LKZ
$structure['columns'][] = array('width' => '10', 'overflow' => 'y'); // PLZ
$structure['columns'][] = array('width' => '20', 'overflow' => 'y'); // Ort
// identify column names and associated labels
$structure['body']['fields'][] = array('kontakt_name' => 'Name');
$structure['body']['fields'][] = array('kontakt_vorname' => 'Vorname');
$structure['body']['fields'][] = array('kontakt_strasse' => 'Strasse');
$structure['body']['fields'][] = array('kontakt_lkz' => 'LKZ');
$structure['body']['fields'][] = array('kontakt_plz' => 'PLZ');
$structure['body']['fields'][] = array('kontakt_ort' => 'Ort');
// define contents of page footer
$structure['foot1'][] = array('type' => 'date', 'align' => 'left', 'style' => 'textalignleft');
$structure['foot1'][] = array('type' => 'pageno', 'align' => 'center');
$structure['foot1'][] = array('type' => 'time', 'align' => 'right', 'style' => 'textalignright');
$structure['foot2'][] = array('text' => 'This is a piece of text', 'align' => 'center');
?>
Can you see something wrong?
And the report file:
?>
The dict.inc file:
|
|
|
Re: Error running output2 pattern [message #4342 is a reply to message #4341] |
Sat, 12 July 2014 03:15 |
AJM
Messages: 2367 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
I repeat, none of the tasks which I generate using the OUTPUT2 pattern exhibit this behaviour, therefore the problem does not exist in my code.
I suggest you find a way of seeing what is being output to cause this error. You might want to use a debugger so that you can step through the code line by line and see what is being written to the output buffer.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
|
|
|
|
|
Re: Error running output2 pattern [message #4453 is a reply to message #4452] |
Wed, 13 August 2014 06:28 |
AJM
Messages: 2367 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
You don't need to step through any of the code which actually produces the PDF document because the problem is being caused by something being written to the output stream BEFORE that point. You need to turn on output buffering then check the output from ob_get_length() as you step through your code. The length should remain at zero at all times until the PDF output is produced.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
|
|
Re: Error running output2 pattern [message #4457 is a reply to message #4456] |
Wed, 13 August 2014 10:59 |
AJM
Messages: 2367 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
The number of code lines is irrelevant. The trick is to step over a function to see if the error occurred in that function or not. If it did not then you can ignore that function, but if it did then you have to restart the debugging session and this time step into the function to see exactly which line causes the problem.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
Re: Error running output2 pattern [message #4533 is a reply to message #4457] |
Mon, 08 September 2014 12:20 |
htManager
Messages: 433 Registered: May 2014
|
Senior Member |
|
|
I still struggle with the problem to output pdf files.
For output2 pattern I have inserted ob_clean(); in line 7588 and it works.
switch($dest) {
case 'I': {
// Send PDF to the standard output
ob_clean();
if (ob_get_contents()) {
$this->Error('Some data has already been output, can\'t send PDF file');
}
Printing output3 pattern doesn't work, so I added var_dump(headers_list()); in line 7598
if (php_sapi_name() != 'cli') {
// send output to a browser
var_dump(headers_list());
header('Content-Type: application/pdf');
I got this array:
array (size=5)
0 => string 'X-Powered-By: PHP/5.4.7' (length=23)
1 => string 'Expires: Thu, 19 Nov 1981 08:52:00 GMT' (length=38)
2 => string 'Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0' (length=77)
3 => string 'Pragma: no-cache' (length=16)
4 => string 'Content-type: text/html' (length=23)
Can this be a problem with the php version 5.4.7?
I run Windows 7, MySQL 5.5.27 in a xampp environment.
Is your development environment the same or different?
[Updated on: Mon, 08 September 2014 12:36] Report message to a moderator
|
|
|
Re: Error running output2 pattern [message #4534 is a reply to message #4533] |
Mon, 08 September 2014 12:52 |
AJM
Messages: 2367 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
There are 11 examples of the OUTPUT2 pattern in the Radicore download, and in the demonstration application which is available at http://www.radicore.org/demo.php, and none of these have the problem you describe. The problem must be because of code which you have generated, so you need to compare my code (which works) with your code (which fails).
You need to step through with your debugger to find exactly where the faulty output is being generated. I cannot do this unless you send me all of your code, and your database, so that I can run it through the debugger on my PC.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
Re: Error running output2 pattern [message #4537 is a reply to message #4536] |
Tue, 09 September 2014 05:22 |
AJM
Messages: 2367 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
I unzipped that file and installed it into my test environment, but I am unable to run anything due to missing files. There are two items in the 'HTM' menu, but neither of them work. When I click on the tabs all I see are the following error messages:
File name 'htm_db_kontakte_typ(list1).php' does not exist
File name 'htm_db_tree_type(list1).php' does not exist
Please send me the missing files.
I will also need your database schema with some test data.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
Re: Error running output2 pattern [message #4539 is a reply to message #4538] |
Tue, 09 September 2014 06:56 |
AJM
Messages: 2367 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
You did not supply the export files with the expected names nor in the expected directories. Please do the following:
1) Go to Menu -> Subsystem, select 'HTM' and press the 'Export' button. This will create the file 'htm.menu_export.sql' in the 'sql' directory.
2) Go to Dictionary -> Database, select 'HTM' and press the 'Export' button. This will create the file 'htm.dict_export.sql' in the 'sql' directory.
I do *NOT* want a dump of your entire menu and dictionary databases, just those export files for the single subsystem.
Your database schema is supposed to be contained in the 'htm/sql/mysql/ directory, not the 'htm' directory.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
Re: Error running output2 pattern [message #4545 is a reply to message #4542] |
Wed, 10 September 2014 09:08 |
AJM
Messages: 2367 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
This was a tricky error! It was caused by a Byte Order Mark being output when a UTF8-encoded language_text.inc file was included when performing the getLanguageText() function. I have changed the code in std.pdf.class.inc to turn on output buffering and to remove any Byte Order Mark before attempting to output the PDF document. See attached zip file for the amended scripts.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
|
Goto Forum:
Current Time: Mon Nov 18 04:23:08 EST 2024
Total time taken to generate the page: 0.03668 seconds
|