I'm currently generating some invoices with odtphp. (https://github.com/cybermonde/odtphp)
I made a segment that contains a table which will be dynamic (and therefore also use a segment) so i use the [!-- BEGIN row.segmentname --] and [!-- END row.segmentname --] tags.
My first segment is working but the row segment won't work.
Here's the error it prints:
Fatal error: Uncaught exception 'OdfException' with message ''details' segment not found in the document
Here's the part of the code that's not working:
Has anyone experienced this?
while ($row = mysql_fetch_array($res))
{
$segment->setVars("codearticle", $row['codearticle']);
$segment->setVars("designation2", $row['designation']);
$segment->setVars("qte", $row['quantite']);
$segment->setVars("prixvente", $row['prixvente']);
$segment->setVars("totalpiece", $row['montantvente']);
$segment->merge();
}
$odf->mergesegment($segment);
What should I do to make this work?
So, after a while of fiddling with my php code, i opened content.xml (from the odt archive) with my text editor and saw that some parts of the text were separated by some xml markups.
I edited it and it seems to find the row tag.
I still have some minor problems, it won't get into my while loop, but at least this part works!
Related
I am using a module in joomla called blank module which unfortunately does not come with much documentation. It allows you to specify HTML code and php. However the php output is always on a new line.
Is there any way in php where you can move the cursor back to the previous line before echoing output.
Current Behaviour
HTML OUTPUT
PHP OUTPUT
Desired Behaviour:
HTML OUTPUT PHP OUTPUT
by coding in moving to previous line in php.
In the end I did not find a solution with PHP but assigned a css tag to the second output and used:
position: relative;
tag to move the output!
A bit of a cheat but got the required results!
This can the first bit of documentation for Joomla blank module.
I'm a beginner with XML on PHP. My page returns me the following PHP error:
But, at line 2, there only is a "require_once", followed by 3 others "require_once", the path to the required file is ok, and it ends with a ';'. The line above is the "
I have this sample of code, which I think is the source of this error (in this order)
$xml = simplexml_load_string("<result/>");
$entitlements = $xml->addChild("entitlements");
$entitlements->addChild("productId", $productId);
then, below :
$fulfillmentXML = new SimpleXMLElement($result);
//some stuff with $fullfillmentXML
echo $xml->asXML();
I do not understand exactly how the XML works in PHP, but I thought there was a problem creating a SimpleXMLElement() after the simplexml_load_string() call.
Your error doesn't look like a PHP error, but rather a browser error generated when it tried to parse the supplied XML contents. Therefore line 2 of the error does not refer to line 2 of your PHP file, but to line 2 of your generated output.
Check your output (source of your generated page), and see what line 2 is there. Make sure you only have 1 root element, and that nothing comes after it.
Like many others out there i have had my fair share of issues trying to download an Excel file output by PHPExcel.
What happened in my case was whenever I wanted to download a file using
$obj->save('php://output')
i always used to get garbled text in my excel file with a warning saying my file was corrupt. Eventually i resolved the issue. The problem being i had a
require('dbcon.php')
at the top of my php script. I just replaced that with whatever was there inside dbcon.php and it worked fine again.
Though the problem is solved i would really like to know what caused the problem. It would be great if anyone out there could help me out with this one.
Thanks.
If you get that error - you should follow the advice we always give in that situation: you use a text editor to look in the generated file for leading or trailing whitespace, or plaintext error messages - and then in your own scripts for anything that might generate that such as echo statements, blank lines outside ?> <?php, etc.
Another way of testing for this is to save to the filesystem rather than php://output and see if you get the same problem: if that works, then the problem is always something that your own script is sending to php://output as well.
Clearly you had a problem along those lines in your dbcon.php file. This can be as simple as a trailing newline after a closing ?> in the file...
Tanmay.
In situations like your's, there can be couple of reasons for broken output:
in file dbcon.php can be a whitespace before opening or ending php
tag, so that produce some chars to output and can make file broken
(this is reason for using only opening tag in php 5.3+);
maybe file dbcon.php wasn't found by require, so you got error message in otput;
any other errors or notices or warnings in dbcon.php, because presence of global vars from current file..
I have spent the last several hours pulling my hair out trying to figure out the solution to this problem. I am sending an AJAX request which, up until some minor changes, worked perfectly, returning a lovely usable character to the Javascript. Now, however, a \r\n is being returned, and I have spent far too long tracking it down. My final method for finding where it was being included was literally echo-ing "OMG" in various places around my scripts until it showed up on Line 2 of the HTML instead of Line 1. Here is the offending script:
// Import Global Game Variables
include('../engine/engine_core_functions.php');
// Convert our gamestate(gameID)
//$curGamestate = getCurrentGamestate($gameID);
// Make sure it's a valid turn
if(isMyTurn()) {
// Draw a card from the card drawing mechanism
$cardValue = drawCard();
$cardValue = str_replace("\r", 'R', $cardValue);
echo $cardValue;
}
else echo 'Error 3';
The line skip occurs immediately after the include file at the top. Before the include, no line break, after the include, line break. So I go to the include file. Placing my
echo 'OMG!';
at the VERY END of the included file does NOT produce a line break. Which led me to believe that including a file may (why!?) generate a line break (it's 5 AM...). However, there are multiple included files at the top of the offending included file. None of them generate breaks. The entire "engine_core_functions.php" generates no line breaks at all.
However, a break shows up when it is included in the above-shown script. Needless to say, I'm baffled and extremely annoyed. I could simply remove the offending characters (via PHP or Javascript) but it annoys me I can't seem to fix the root of the problem. Please help, thank you.
You could have some kind of invisible BOM mark at the beginning of your file or something else.
Always let <? or <?php be the first string of your PHP files and make it a practice NOT to end the entire PHP file with ?> if it's going to be included by another file.
I am using a html minifier, which can be found here: HTML minify
The strange thing to me is that every tag is placed on a new line. Is this common behavior or am I doing something wrong. The output looks something like this:
Anyone know how I can fix this so that is just creates one line of code, or is has this was of minifying some advantages.
Checked the code?
// use newlines before 1st attribute in open tags (to limit line lengths)
$this->_html = preg_replace('/(<[a-z\\-]+)\\s+([^>]+>)/i', "$1\n$2", $this->_html);
Long lines can be a bad bad thing - browsers might fill buffers or just drop stuff at the end of the line. So it looks like that Minify script has it hard coded in, with no options to change. So if you really want it all on one line, just customise your version to not do that replacement. Open Source win.