I'm trying to deal with Excel sheets in PHP and the following code causes irritating problems.
$getOrderFile = $this->db->query("SELECT order_file FROM orders WHERE id='".$order."'")->fetch_assoc();
$excelReader = PHPExcel_IOFactory::createReaderForFile('xls/'.$getOrderFile["order_file"]);
$excelReader->setReadDataOnly(true);
$Excel = $excelReader->load('xls/'.$getOrderFile["order_file"]);
return $Excel->setActiveSheetIndex(0)->getHighestRow();
Now, I checked the script with two variants of $getOrderFile["order_file"]:
1. excel1.xlxs
2. excel1.xls
When $getOrderFile["order_file"] equals excel1.xlxs - the page goes completely blank. There's no content displayed. And should there be any additional text in HTML - it isn't displayed. As if there was "exit;" somewhere but isn't.
When $getOrderFile["order_file"] equals excel1.xls - the pages goes "missing". I get "The webpage is not accessible" (404).
Can somebody tell me what is wrong? I just want to get the rowcount and... well. The whole system goes nuts.
Thanks for your help!
Related
I have continued my voyage into creating a extremely simple template engine.
Because I wanted to add logic to my template I eventually got back to the point that I allowed PHP tags into my code which I enabled by evalling the code.
Maybe not the best solution but when looking at the WordPress templates I noticed that the idea itself may not be that bad.
But now there still is one small problem left.
And that is that I want to translate the generated code.
But it has been evalled already. Hence parsed.
I thought of solving this problem by using ob_get_contents().
But this brought one more question and in case of errors it shows a white screen. (memory usage etc.)
Plus it still did not take away the problem of eval that it parsed the contents when evalled.
In short the class logic is:
Loading template files
Adding the contents
Compiling the template
Eval the code (but unfortunately also displaying the code)
Translate the code so I can translate the code parsed by a PHP script
I would love something like:
$code = eval('?>'.$tpl.'<?php');
$code = translate($code);
WriteCache($code);
SetDocumentHeader();
echo $code;
Would anyone know how to achieve this?
Thanks in advance!
$code = eval($tpl);
Check this out.
I don't know what happened, but barcode39.php class is just not working anymore. If You follow the link http://eventstar.hu/api/code39/BARCODE-123456789101 , You can see that there's a broken image link, however, the image was generated directly to the browser by the PHP class with the correct headers (image/gif). If you view the source (type "view-source:" before the URL in Chrome), You can see that the image data was here, starting wih GIF...
The code was not too complex. page_attr[1] is the end of the URL, in this case : BARCODE-123456789101. The following snippet was wrapped inside if($page_attr[0]=="code39"), but it's irrelevant, because it's true.
include("include/barcode39/barcode39.class.php");
$bc = new Barcode39($page_attr[1]);
$bc->barcode_text_size = 2;
$bc->barcode_bar_thick = 2;
$bc->barcode_bar_thin = 1;
$bc->barcode_use_dynamic_width = false;
$bc->barcode_width = 300;
$bc->barcode_padding = 7;
$bc->draw();
exit;
Can a PHP update cause the problem? Or something is wrong with my code? I don't touch these files weeks ago, hovewer the barcode generator doesn't work anymore... Any suggestions?
Finally, someone pointed out that the encoding of the PHP file itself can cause problems. So everyone facing this problem, make sure You saved the file in UTF-8 without BOM!
I'm very new to the idea of adding values to a database, so would like some advise on whether this is possible and how I would do it.
I have a code that counts the lines of code written in a project, the code has to be in the folder that it is counting the lines of code from however I want to display this number on my site elsewhere. My site is a wordpress one, so i thought of sending this number to the database and calling on it in a template file elsewhere.
Is there a way to send this number to my database and have it keep up to date in real-time so that I can call it from other places in my site?
My LOC script can be seen running here:
http://www.skizzar.com/wp-content/loc.php
and the number is displayed using the command:
$folder -> count_lines()
update
I've added the following code to my loc.php
$num_of_lines = $folder -> count_lines();
add_option('line_count', $num_of_lines);
And called it in my theme files using
echo get_option('line_count', '0');
So far this just returns 0 as the value and causes a fatal error on loc.php "call to undefined function..."
Second update
Got the code to work by adding
require_once('wp-config.php');
To the top of my code, the issue now is that it doesn't update in real time - is there a way to do this?
Assuming you are saving the value to the database with wordpress as well, use add_option and get_option. Something like this:
add_option('line_count', $num_of_lines);
And in your template, display it with:
echo get_option('line_count', '0');
im using vtiger crm 5.4.0..its awesome..
but i have 1 problem, regarding to Quotes Module, Invoice Module and other module which Generate PDF for print.
If that generated Quotes is of 3-4 pages then how to remove/hide Header part like Compny Name,logo, customer details on 2nd page?
Header part is showing on all 3-4 pages of Quotes.. Is it comes under any setting or coding part plz letme know.. in attached file i have colored that parts, i want those header in 1st page not in upcoming pages..
Thanks You.
i found best alternative to it, this tool/plugin can edit pdf as our need..
hope this work for you too..cheers..
http://forge.vtiger.com/projects/pdfmakerfree/
tutorial:
http://www.its4you.sk/images/pdf_maker/pdfmakerfree-for-vtigercrm.pdf
Finally i solved this issue with some coding changes..
in filepath vlib/vtiger/PDF/inventory/Headerview.php
edit some code in that file (approx line number 26), in followinf function just add 1 condition
function display($parent) {
$pdf = $parent->getPDF();
$page2 = $pdf->getPage();
if($page2 <= 1)
{
//function code goes here
}
}
I apologize if this has been answered, but I haven't been able to find anything about it. I've been having trouble with a certain block of PHP code on my server and have finally realized that it doesn't like single line comments. With this code, the method get_all_articles is never called.
<?php
$article_class = new Articles();
// Fetch all articles
$articles = $article_class->get_all_articles();
?>
However, removing the comment or converting it to a block comment allows the page to render perfectly. I realize that I've already figured out what's causing the problem, but what I'm looking for is why or how I might be able to fix it. Any help would be greatly appreciated. Thanks!
Maybe the formatting is getting lost on upload to where line breaks are being deleted? Try downloading the PHP file after you've uploaded it and see if the line breaks are still intact.
This can be frustrating... One time I had an if statement that would ALWAYS execute, no matter what the values were...
Started out as this, where $x was equal to 5 (I verified this with debugging)
if($x > 10);
{
....
}
Eventually, I had it down to this:
if(false);
{
echo("This should never happen");
echo("but it does!!!!!!!");
}
After much loss of hair, I realized that I had a semi-colon at the end of the if() line, therefore translating into:
if(false)
/*do nothing*/;
{
//Nice block that always executes
}
The moral of this story is that while the problem you percieve is actually giving you a problem, it is not a PHP problem. Try to find out the root cause by first verifying that the actual code that is executing is EXACTLY what you typed. Re-download the file, publish with different protocol, publish as binary, check sha1sum() on files to make sure the same... Look and look and you will find it.
Let us know.