Error with FPDF - php

I don't know why but my pdf batch does'nt work and now I have this error.
The problem come from the class inside the while loop
Thank you
Notice: OM\Registry::set - Order already registered and is not forced to be replaced in /home/www/shop/includes/OM/Registry.php on line 33
Fatal error: Uncaught Exception: FPDF error: Some data has already been output, can't send PDF file in /home/www/boutique/ext/fpdf/fpdf.php:271 Stack trace: #0 /home/www/boutique/ext/fpdf/fpdf.php(1063): FPDF->Error('Some data has a...') #1 /home/www/boutique/ext/fpdf/fpdf.php(999): FPDF->_checkoutput() #2 /home/www/boutique/admin/invoice_batch.php(570): FPDF->Output() #3 {main} thrown in /home/www/boutique/ext/fpdf/fpdf.php on line 271
This error is in relation with this element
// Classe pdf.php
$pdf = new \FPDF();
// $pdf->SetWidths(array(30,50,30,40));
while ($QordersInfo->fetch()) {
Registry::set('Order', new OrderAdmin($QordersInfo->valueInt('orders_id')));
$order = Registry::get('Order');
...
..
}
// PDF's created no
// output the file
$pdf->Output();
If I write this it "works perfectly" but it display only 1 invoice.
// Classe pdf.php
$pdf = new \FPDF();
// $pdf->SetWidths(array(30,50,30,40));
while ($QordersInfo->fetch()) {
Registry::set('Order', new OrderAdmin($QordersInfo->valueInt('orders_id')));
$order = Registry::get('Order');
.....
// output the file
$pdf->Output();
}

It is difficult to trace the problem without knowing what Registry::set() does, but it looks like the first parameter of that function should be a unique key. In your code the key is always 'Order' in every iteration of the loop. The first iteration will be fine, but in the second iteration it will generate output to give you a Notice that there already is a Registry entry with that key.
The $pdf->Output() function checks to see if anything in your PHP code has already produced any output. Because the Notice was sent to output, FPDF cannot start rendering and produces the FPDF error to let you know.
Either use a unique key (perhaps the ID of the order?) or force the Registry entry to be replaced in every iteration. If that does not get you on track again, post the Registry class code so we can delve deeper into the problem.

Related

Cloudinary AI background removal fatal error

I am trying to use Cloudinary AI background removal tool. This is the code I am using (Code snippet provided by Cloudinary)
if(isset($_POST["submit"])){
\Cloudinary\Uploader::upload("https://www.popwebdesign.net/popart_blog/wp-content/uploads/2019/05/slike-prirode-za-desktop-757.jpg",
array(
"public_id" => "dog_couch",
"background_removal" => "cloudinary_ai"
));
}
I get this error
Fatal error: Uncaught Error: Class 'Cloudinary\Error' not found in /storage/ssd5/884/7393884/public_html/Uploader.php:534 Stack trace: #0 /storage/ssd5/884/7393884/public_html/Uploader.php(408): Cloudinary\Uploader::call_api('upload', Array, Array, 'https://www.pop...') #1 /storage/ssd5/884/7393884/public_html/Uploader.php(101): Cloudinary\Uploader::call_cacheable_api('upload', Array, Array, 'https://www.pop...') #2 /storage/ssd5/884/7393884/public_html/index.php(13): Cloudinary\Uploader::upload('https://www.pop...', Array) #3 {main} thrown in /storage/ssd5/884/7393884/public_html/Uploader.php on line 534
When I use part just for uploading it works perfectly
if(isset($_POST["submit"])){
\Cloudinary\Uploader::upload("https://www.popwebdesign.net/popart_blog/wp-content/uploads/2019/05/slike-prirode-za-desktop-757.jpg");
}
as soon as I add array part I get the error. I can't see what I am doing wrong since this code is directly from cloudinary. I've found it here: https://cloudinary.com/documentation/cloudinary_ai_background_removal_addon
I have tried to search the internet, but could not find a solution for this.
Any help is appreciated!

PHP mysqli functions fatal ERROR when using the query function

I am programming a website and my current task is to save the text on a mysql server so I can login as admin and then edit the displayed text online.
I already got so far that everything works but I have done it using mysql functions. Now changed all those functions to mysqli ones, since I heard those are way better.
Here is my mysql_connect.php which I created so I could include this in the other scripts wherever I need to connect to the server:
mysql_connect.php
This is my block1_aboutme.php file, where I connect to the server and request all the text from it so I can display it on my "about me" page. This also works as intended and it properly displays the text on my page.
block1_aboutme.php
The problem is when I login as an admin a part of the login verification is this code below in my class.login.php script. As soon as I am logged in and go to my aboutme page an error occurs:
Fatal error: Uncaught Error: Call to a member function query() on unknown in C:\xampp\htdocs\mywebsites\LuPaw\admin\class.login.php:84 Stack trace: #0 C:\xampp\htdocs\mywebsites\LuPaw\admin\class.login.php(73): Login->verifyDatabase() #1 C:\xampp\htdocs\mywebsites\LuPaw\admin\class.login.php(36): Login->verifySession() #2 C:\xampp\htdocs\mywebsites\LuPaw\aboutme.php(42): Login->isLoggedIn() #3 {main} thrown inC:\xampp\htdocs\mywebsites\LuPaw\admin\class.login.php on line 84
This error refers to line 84 which is the $data = $db-> query("select stuff") function.
Somehow this does not work here, while the nearly exact same code line does work in the block1_aboutme script.
I would place the link of my 3rd script here but I can't since I don't have reputation pints yet to place 3 links in one post. Will post 3rd picture in the comments.
I already tried out a few things. If I for example echo out the "$path" it shows the correct path which means $db should be a viable variavble.
Does anyone see the problem here?
Try not to use include_once in your class method as the file will not be included if anywhere during the script execution has been already included: use include instead.
Anyway this is not the best solution you can achieve, I can suggest you to implement a DB class as a singleton and then retrieve the database instance in order to execute your queries.

GAPI: Failed to request report data and provides no further information

We're using the PHP GAPI ([https://code.google.com/p/gapi-google-analytics-php-interface/) to retrieve data and to show graphs in admin panel of our websites.
We know this library hasn’t been updated since 2009, but it was working fine for us for a long time until some months ago...
Bellow is the error we got :
Fatal error:
Uncaught exception 'Exception' with message 'GAPI: Failed to request report data.
Error: "Request failed, fopen provides no further information"' in /www/clientname/site/lacentrale/gapi.class.php:218
Stack trace:
#0 /www/clientname/site/cms/include.dashboard.analytics.visits.php(37): gapi->requestReportData('95220065', Array, Array, Array, NULL, '2014-11-23', '2014-12-22', 1, 30)
...
#6 {main} thrown in /www/clientname/site/cms/gapi.class.php on line 218
Here is the code for include.dashboard.analytics.visits.php — lines 35 to 39 (error on line 37):
if ( ! $ga = $myCache->getCache() ){
$ga = new gapi(ga_email,ga_password);
$ga->requestReportData(ga_profile_id,array($dimension),array('visits','pageviews','timeOnSite','avgTimeOnSite','pageviewsPerVisit'),array($dimension),null,$begin,$end,1,$max);
$myCache->saveCache($ga);
}
And here is the code for gapi.class.php — lines 212 to 219 (error on line 218):
if(substr($response['code'],0,1) == '2')
{
return $this->reportObjectMapper($response['body']);
}
else
{
throw new Exception('GAPI: Failed to request report data. Error: "' . strip_tags($response['body']) . '"');
}
We don’t fully understand these errors which are not so clear, and as nothing changed in these files...
As we seen on other StackOverflow tickets and other forums, we've already checked our profile ID which is the good one (8 digits after the p in the Google Analytics URL).
We would like to not move to another PHP API for GA (if any other available? what would be the best solution as of today?) because it would required a lot a work to implement again the admin panel we've made ...
Many thanks for your help!
Problem solved : we had made modifications into the gapi.class.php file since a long time for a project which required special securised specifications for server connection and we were still using this file modified in other projects which do not required this modifications...
So we downloaded a clean copy of GAPI and replaced with the initial file to solve the problem ;-)

creating events through zend

in my server i downloaded and uploaded the zend gdata library.then as a test i created a seperated folder and checked whether its working. and yes it worked.so i kept the folder structure as it is and moved the files in to my app. then it gave me an error like this.even if i tried the same code which i used in the test folder, it gives me the same error.please help me.
error
Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 400 [Line 1, Column 451, element gd:when] Badly formatted datetime' in /var/www/vhosts/eyepax.info/rsdesign.eyepax.info/emailApp2/Zend/Gdata/App.php:714 Stack trace: #0 /var/www/vhosts/eyepax.info/[host]/emailApp2/Zend/Gdata.php(219): Zend_Gdata_App->performHttpRequest('POST', 'https://www.goo...', Array, 'performHttpRequest('POST', 'https://www.goo...', Array, 'performHttpRequest('POST', 'https://www.goo...', Array, 'performHttpRequest('POST', 'https://www.goo...', Array in /var/www/vhosts/eyepax.info/[host]/emailApp2/Zend/Gdata/App.php on line 714
if this is a fault with the library, please tell me what to do..
in the test folder i have 2 files and the folder named Zend...i used the following code as a class and used it's example code to test it.and it worked. my problem is why is it not working in my app?
class=http://www.phpclasses.org/browse/file/28780.html
i received this error for several reasons. my time offset was not correct.and the way i entered the time was incorrect aswell. it should be HH:MM:SS not HH.MM.SS . hope this helps someone

PHP reporting error on wrong line

I have what appears to me, to be two identical text files, I copy and paste exactly the same (intentionally erroneous) content in them, being the following:
<?
//error code
$sSQL = "SELECT error";
fakefunction();
?>
But I get this in tab #1 of my browser:
Fatal error: Call to undefined function fakefunction() in
/home/public_html/notes/textfileone.php on line 3
And I get this in tab #2 of my browser (the same browser as tab #1 is in):
Fatal error: Call to undefined function fakefunction() in
/home/public_html/notes/textfiletwo.php on line 4
Any idea why this would be happening?
Possibly one of them is being saved with a Byte Order Mark and one without? That would add one more line to the content. Your text editor might be adding it upon save, but hiding it otherwise.

Categories