I'm trying to insert an image in a FPDF fancytable.
I tried to put inside the fancytable function the following :
$this->Cell($w[1],6,$pdf->Image('lettre.jpg',0,0,20,0),'LRB',0,'C',$fill);
but I have (of course) the following error message :
PHP Notice: Undefined variable: pdf in /MyScript.php on line 143
Notice: Undefined variable: pdf in /MyScript.php on line 143
PHP Fatal error: Uncaught Error: Call to a member function Image() on
null in /MyScript.php:143
Stack trace:
0 /MyScript.php(172): PDF->FancyTable(Array, Array)
1 {main} thrown in /MyScript.php on line 143
I understand that I call the pdf function inside the fancytable function (part of the pdf function), so do I have a solution ?
Thanks !
Damn, the answer was in the question : just replaced $pdf by $this and it fixed my problem..
I let the question here just in case somebody have the same error one day ^^
Related
I need some help in understanding the following things,
I am using composer for elasticsearch php integration. I have created a html page to post form data into elasticsearch. I am trying to access the html page from another pc by changing the localhost ip to the system ip where i have hosted the html page. But i'm getting error.
Fatal error: Uncaught Elasticsearch\Common\Exceptions\NoNodesAvailableException: No alive nodes found in your cluster in C:\xampp\htdocs\Client_portal\vendor\elasticsearch\elasticsearch\src\Elasticsearch\ConnectionPool\StaticNoPingConnectionPool.php:50 Stack trace: #0 C:\xampp\htdocs\Client_portal\vendor\elasticsearch\elasticsearch\src\Elasticsearch\Transport.php(77): Elasticsearch\ConnectionPool\StaticNoPingConnectionPool->nextConnection() #1 C:\xampp\htdocs\Client_portal\vendor\elasticsearch\elasticsearch\src\Elasticsearch\Transport.php(94): Elasticsearch\Transport->getConnection() #2 C:\xampp\htdocs\Client_portal\vendor\elasticsearch\elasticsearch\src\Elasticsearch\Connections\Connection.php(269): Elasticsearch\Transport->performRequest('POST', '/sib_api/_doc', Array, '{"requestid":"#...', Array) #3 C:\xampp\htdocs\Client_portal\vendor\react\promise\src\FulfilledPromise.php(25): Elasticsearch\Connections\Connection->Elasticsearch\Connections{closure}(Array) #4 C:\xampp\htdocs\Client_portal\vendor\guzzlehttp\ringphp\sr in C:\xampp\htdocs\Client_portal\vendor\elasticsearch\elasticsearch\src\Elasticsearch\ConnectionPool\StaticNoPingConnectionPool.php on line 50
To resolve the above issue i tried to call the autoload.php file using the complete path (i.e) http://localhost:8080/client_portal/vendor/autoload.php
But now I am getting another error
Fatal error: Uncaught Error: Class 'Elasticsearch\ClientBuilder' not found in C:\xampp\htdocs\Client_portal\Elastic_api.php:19 Stack trace: #0 {main} thrown in C:\xampp\htdocs\Client_portal\Elastic_api.php on line 19
Could someone help me to resolve this issue... and also guide me how to access my html page from another system without any isssues.
<?php
session_start();
$Engagement = $_SESSION["Engagement"];
$Application = $_SESSION["Application"];
$Priority = $_SESSION["Priority"];
$Requestid = $_SESSION["Requestid"];
$_SESSION["URL"] = $_POST['url'];
$_SESSION["REQ"] = $_POST['request'];
$_SESSION["RES"] = $_POST['response'];
$_SESSION["yn"] = $_POST['YN'];
$_SESSION["START"] = $_POST['start'];
$_SESSION["END"] = $_POST['end'];
if (isset($_POST['Submit2']))
{
require 'http://localhost:8080/client_portal/vendor/autoload.php';
$client = Elasticsearch\ClientBuilder::create()->build();
// the above line is where i'm getting the error...
I was getting deprecated constructor error when I tried installing postgres with xampp. Though I was able to resolve those issues but I am unable to solve the one below. Kindly help to solve this.
Fatal error: Uncaught Error: Call to undefined method ADORecordSet_postgres7::ADORecordSet_postgres64() in C:\xampp\phppgadmin\libraries\adodb\drivers\adodb-postgres7.inc.php:220 Stack trace:
#0 C:\xampp\phppgadmin\libraries\adodb\adodb.inc.php(1055): ADORecordSet_postgres7->__construct(Resource id #19, 2)
#1 C:\xampp\phppgadmin\libraries\adodb\adodb.inc.php(1015): ADOConnection->_Execute('select version(...', false)
#2 C:\xampp\phppgadmin\libraries\adodb\adodb.inc.php(1427): ADOConnection->Execute('select version(...', false)
#3 C:\xampp\phppgadmin\libraries\adodb\drivers\adodb-postgres64.inc.php(129): ADOConnection->GetOne('select version(...')
#4 C:\xampp\phppgadmin\libraries\adodb\drivers\adodb-postgres64.inc.php(697): ADODB_postgres64->ServerInfo()
#5 C:\xampp\phppgadmin\libraries\adodb\adodb.inc.php(525): ADODB_postgres64->_connect('host='localhost...', ''postgres'', ''password'', ''template1'')
#6 C:\xampp\phppgadmin\classes\database\Connection.php(42): ADOConnection->Connect('localhost:5432:...', 'postgres', ' in C:\xampp\phppgadmin\libraries\adodb\drivers\adodb-postgres7.inc.php on line 220
You should also change the constructor in adodb-postgres7.inc.php by replacing
function ADODB_postgres7()
with
function __construct()
I receive this error message:
FatalErrorException in Str.php line 243: Call to undefined function Illuminate\Support\random_bytes()
public static function randomBytes($length = 16) {
return random_bytes($length);
}
line 243: return random_bytes($length);
I do not understand what's wrong since a working version Laravel offline that extract online.
It does not work online though. I wonder why?
random_bytes is a PHP 7 function.
I'm assuming that your offline/development stack has PHP 7 installed but not online/production.
Confirm your hosting for PHP 7 installed.
I'm trying to import a pdf with php class FPDI with this simple code:
require_once("fpdf/fpdf.php");
require_once("fpdi/fpdi.php");
$pdf = new FPDI();
$pdf->setSourceFile('intermedia.pdf');
$tplidx = $pdf->ImportPage(1);
$pdf->AddPage();
$pdf->useTemplate($tplidx,0,0,210);
$pdf->Output();
but I receive the following error:
Warning: explode() [function.explode]: Empty delimiter. in
/var/catalogo/test_pdf/fpdi/pdf_parser.php on line 369
Fatal error: Uncaught exception 'Exception' with message 'Unable to
find object (1, 0) at expected location.' in
/var/catalogo/test_pdf/fpdi/pdf_parser.php:709 Stack trace: #0
/var/catalogo/test_pdf/fpdi/pdf_parser.php(268):
pdf_parser->resolveObject(Array) #1
/var/catalogo/test_pdf/fpdi/pdf_parser.php(208):
pdf_parser->_readRoot() #2
/var/catalogo/test_pdf/fpdi/fpdi_pdf_parser.php(71):
pdf_parser->__construct('/var/catalogo/t...') #3
/var/catalogo/test_pdf/fpdi/fpdi.php(128):
fpdi_pdf_parser->__construct('/var/catalogo/t...') #4
/var/catalogo/test_pdf/fpdi/fpdi.php(108):
FPDI->_getPdfParser('/var/catalogo/t...') #5
/var/catalogo/test_pdf/index.php(5):
FPDI->setSourceFile('intermedia.pdf') #6 {main} thrown in
/var/catalogo/test_pdf/fpdi/pdf_parser.php on line 709
This is the file that should be imported:
http://catalogo.selectaspa.it/test_pdf/intermedia.pdf
Ok, the cross reference of this file is simply corrupted. I just catched the "Warning" on explode for now but at the end you will have to resave the document with e.g. Acrobat to repair it before passing it to FPDI.
You may change pdf_parser.php around line 362 to:
// get Line-Ending
$found = preg_match_all("/(\r\n|\n|\r)/", substr($data, 0, 100), $m); // check the first 100 bytes for line breaks
if ($found === 0) {
throw new Exception('Xref table seems to be corrupted.');
}
Same fix can be used in the separate FPDI PDF-Parser which will allow you to read this document then, too.
When attempting to import a csv product file into magento it keeps staying at "please wait". After using firebug I found I was getting this error:
Fatal error: Call to a member function prepareAttributesForSave() on a non-object in /magento/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php on line 1259
Here's line 1259 in product.php:
$rowData = $this->_productTypeModels[$productType]->prepareAttributesForSave($rowData);
$product = Mage::getModel('importexport/import_proxy_product', $rowData);
I am a complete newbie to PHP and am not sure how to fix this. I tried searching google, but didn't find anything related to this specific function.