This topic is locked
[SOLVED]

FPDF and PHPRUNNER 10.8

11/20/2022 10:50:28 AM
PHPRunner General questions
konenamogo author

Hello
I am using FPDF to print an invoice. For this I created a button for this purpose (in localhost with FPDF, printing is done successfully).
Below is the error code and message returned to me by phprunner 10.8.

//****
<?php
global $conn;

require ("FPDF/fpdf.php");

// définir la classe myPDF comme fille de la classe FPDF pour d'finir des fonctions supplémentaires
class myPDF extends FPDF {

function header(){

// POUR RECCUPERER LES DONNEES EN TETE (HEADER), FAIRE LA REQUÊTE DANS LA FONCTION HEADER

// 1 - Création de la connexion à la base de donnée
//Connexion à la base de données
//$db = new PDO('mysql:host=localhost;dbname=sistekramatekdepot','root','' );
global $conn;
//RECUPERATION DES DONNEES EN-TETE idclient
$IdCdeClient = $_SESSION['IdCdeClient'];
$results = DB::Query("select * from cdeclient WHERE IdCdeClient = $IdCdeClient",$conn);

IF($data1 = $results->fetchAssoc()){

//RECUPERATION DE TOUTES LES VALEURS UTILE DE L'EN-TETE
$IdCdeClient = $data1['IdCdeClient'];
$NumFacture = $data1['NumFacture'];
$DateFacture = $data1['DateFacture'];
$NomDuClient = $data1['NomDuClient'];
$ContactClient = $data1['ContactClient'];
$NomDeLaVille = $data1['NomDeLaVille'];
$Objet = $data1['Objet'];
$NumBonDeCommande = $data1['NumBonDeCommande'];
$NumCompteContribuable = $data1['NumCompteContribuable'];

}

//***************************LOGO PLUS TEXTE A RECCUPERER AVEC LA REQUETE CI-DESSUS ******
// Logo
$this->Image('SISTEKLOGO1.jpg', 12,7 );
// Police Arial gras 8
$this->SetFont('Arial','B',8);
// Décalage à droite
$this->Cell(62);

//*****

Error message:
Fatal error: Uncaught Error: Call to a member function fetchAssoc() on boolean in C:\xampp\htdocs\StockCom\ICM\blsistek.php:32 Stack trace: #0
C:\xampp\htdocs\StockCom\FPDF\fpdf.php(336): myPDF->header() #1 C:\xampp\htdocs\StockCom\ICM\blsistek.php(356): FPDF->AddPage('P', 'A4', 0) #2 C:\xampp\htdocs\StockCom\blsistek1.php(7):
require('C:\xampp\htdocs...') #3 {main} thrown in C:\xampp\htdocs\StockCom\ICM\blsistek.php on line 32

Is there anyone to help us?

Thanks

admin 11/20/2022

If you need to use PHPRunner's APIs like Database API, make sure to include include/dbcommon.php file.

How to add external files article provide more details.

konenamogo author 11/20/2022

Hello

i include it first in onother php file:

<?php
@ini_set("display_errors","1");
@ini_set("display_startup_errors","1");

require_once("include/dbcommon.php");

require("ICM/blsistek.php");

admin 11/20/2022

This should be enough.

You also need to make sure sure that your code is correct. Why do you add $conn as a second parameter to DB::Query function call?

DB::Query()

konenamogo author 11/20/2022

Hello,

I find the solution of my problem. The script are correct But I do not initialize the session variable in my printing button. This is what was showing the error message

Thanks