Jump to content

Recommended Posts

I have used this program for many years without problems.
My ISP urged me to upgrade PHP to 7.2 and it was working OK.
Just went to use it and I get an error when parsing my FPDF file.
Here is the error:
Connected (added this to check if connected)
Fatal error: Uncaught Error: Call to undefined method PDF::FPDF() in /homepages/30/d593365489/htdocs/Prnpdf.php:78 Stack trace: #0 /homepages/30/d593365489/htdocs/Prnpdf.php(108): PDF->PDF('L', 'mm', 'A4') #1 {main} thrown in /homepages/30/d593365489/htdocs/Prnpdf.php on line 78

I have not altered the file in any way, so why is this happening?

Is it to do with PHP upgrade?😖

Here is the file:

<?php
include("connect_Verses4Cards.php");
$conn=get_db_conn_verse();
session_start();
$display_block ="";

$color="";
$r ="";
$g ="";
$b ="";
$image ="";

//Get the Card Variables
$Get_Size_sql = "SELECT * FROM `CSize` WHERE `Size` ='".$_POST["CSize"]."'";
$Get_Size_res =  mysqli_query($conn, $Get_Size_sql) or die(mysqli_error($conn));

if (mysqli_num_rows($Get_Size_res) < 1) {
	//this Card does not exist
	$display_block = "You have selected an invalid Card size.
	Please try again.";
} else {
	//get the print variables
	while ($Size_info = mysqli_fetch_array($Get_Size_res)) {
		$BoxX = stripslashes($Size_info['BoxX']);
		$Cellw = stripslashes($Size_info['Cellw']);
		$Cellh = stripslashes($Size_info['Cellh']);
		$SizeI = stripslashes($Size_info['Size']);
		$SID = stripslashes($Size_info['SID']);
		$floatx = stripslashes($Size_info['floatx']);
		$floaty = stripslashes($Size_info['floaty']);
		$floatw = stripslashes($Size_info['floatw']);
		$floath = stripslashes($Size_info['floath']);
		$ort = stripslashes($Size_info['ort']);
	}
		//create the display string
		$display_block = "$ort";
}
//verify the Event exists
//$the_id = mysqli_real_escape_string($mysqli, $_SESSION[VID]);
$Get_Verse_sql = "SELECT id, Event, Sub_Type, Verse FROM verses WHERE id='".$_SESSION['Test']."'";  
$Get_Verse_res =  mysqli_query($conn, $Get_Verse_sql) or die(mysqli_error($conn));


if (mysqli_num_rows($Get_Verse_res) < 1) {
	//this Event does not exist
	$display_block = "You have selected an invalid Event.
	Please try again.";
} else {
//get the Event ID
	while ($Verse_info = mysqli_fetch_array($Get_Verse_res)) {
		$Verse = stripslashes($Verse_info['Verse']);
	}
	//create the display string
	$display_block = "$Verse";
	
	//free results
	mysqli_free_result($Get_Verse_res);
	mysqli_free_result($Get_Size_res);
	//close connection to MySQL

}

	mysqli_close($conn);


require('fpdf.php');

class PDF extends FPDF
{
var $B;
var $I;
var $U;
var $HREF;

function PDF($orientation='P', $unit='mm', $size='A4')
{
    // Call parent constructor
    $this->FPDF($orientation,$unit,$size);
    // Initialization
    $this->B = 0;
    $this->I = 0;
    $this->U = 0;
    $this->HREF = '';
}



function SetStyle($tag, $enable)
{
    // Modify style and select corresponding font
    $this->$tag += ($enable ? 1 : -1);
    $style = '';
    foreach(array('B', 'I', 'U') as $s)
    {
        if($this->$s>0)
            $style .= $s;
    }
    $this->SetFont('',$style);
}

}
$color = $_POST['color'];
$r = substr($color,0,3);
$g = substr($color,3,3);
$b = substr($color,6,3);
$image=$_POST['image'];

$pdf = new PDF($ort,'mm','A4');
$pdf->AddPage();
$pdf->AddFont('French Script MT','','/frscript.php');
$pdf->AddFont('Batavia','','Batavia_.php');
$pdf->AddFont('Algerian','','Alger.php');
$pdf->AddFont('Bladerunner','','BLADRMF_.php');
$pdf->AddFont('Brush Script','','BRUSHSCI.php');
$pdf->AddFont('Helterskelter','','Helte___.php');
$pdf->AddFont('Justice','','Justice_.php');
$pdf->AddFont('Magneto','','MAGNETOB.php');
$pdf->AddFont('Old English','','OldEngl.php');
$pdf->AddFont('Sneakerhead Outline','','Sneabo__.php');
$pdf->AddFont('Trendy','','Trendy__.php');
$pdf->AddFont('Vladimir Script','','VLADIMIR.php');
$pdf->SetLeftMargin('float0');
$pdf->SetTextColor($r,$g,$b);
$pdf->SetFont($_POST['fontface'],'',$_POST['font']);
$pdf->SetXY($BoxX, $_POST['Top']);
$pdf->Image($image,$floatx,$floaty,$floatw,$floath,'','');
$pdf->MultiCell($Cellw,$Cellh,$display_block,'' ,'C');
//$pdf->SetDisplayMode('fullpage','');
$pdf->SetFont('');
$pdf->Output('verse.pdf','D');
//end:
?>

 

Link to comment
https://forums.phpfreaks.com/topic/309156-problem-with-fpdf/
Share on other sites

Change

function PDF($orientation='P', $unit='mm', $size='A4')

to

function __construct($orientation='P', $unit='mm', $size='A4')

Giving the constructor function the same name as the class is very PHP version 4 and you can't get away with it any more.

You probably have to make the same amendment in your FPDF class also if it's an old version.

Link to comment
https://forums.phpfreaks.com/topic/309156-problem-with-fpdf/#findComment-1569302
Share on other sites

And also

$this->FPDF($orientation,$unit,$size);

to

parent::__construct($orientation,$unit,$size);

 

Assuming you don't have a very old version of FPDF, it should already be PHP 5 compatible (eg, using __construct) but it hasn't been updated in a few years and says it requires PHP 5.1.

Link to comment
https://forums.phpfreaks.com/topic/309156-problem-with-fpdf/#findComment-1569308
Share on other sites

Tried as suggested but get the same error!

Fatal error: Uncaught Error: Call to undefined method FPDF::FPDF() in /homepages/30/d593365489/htdocs/Prnpdf.php:78 Stack trace: #0 /homepages/30/d593365489/htdocs/Prnpdf.php(108): PDF->__construct('L', 'mm', 'A4') #1 {main} thrown in /homepages/30/d593365489/htdocs/Prnpdf.php on line 78

Also tried amending this line: $pdf = new PDF($ort,'mm','A4');  to: $pdf = new __construct($ort,'mm','A4');, but that did not work and gave this error:

Fatal error: Uncaught Error: Class '__construct' not found in /homepages/30/d593365489/htdocs/Prnpdf.php:108 Stack trace: #0 {main} thrown in /homepages/30/d593365489/htdocs/Prnpdf.php on line 108.

Where do I go rom here?

😂

 

Link to comment
https://forums.phpfreaks.com/topic/309156-problem-with-fpdf/#findComment-1569364
Share on other sites

You're createing a PDF object so that bit "new PDF()" stays the same

require('fpdf.php');

class PDF extends FPDF
{
    private $B;
    private $I;
    private $U;
    private $HREF;

    function __construct($orientation='P', $unit='mm', $size='A4')
    {
        // Call parent constructor
        parent::__construct($orientation,$unit,$size);
        // Initialization
        $this->B = 0;
        $this->I = 0;
        $this->U = 0;
        $this->HREF = '';
    }

}

...

$pdf = new PDF('L');

 

Edited by Barand
Link to comment
https://forums.phpfreaks.com/topic/309156-problem-with-fpdf/#findComment-1569366
Share on other sites

I think it was the parent bit that was stopping it!

However there are still problems! 

Here is the error:

Now I have cleared the original problem, It still errors!
Now it is finding fault with the font scripts. Here is the error:

Fatal error: Uncaught Exception: FPDF error: Incorrect font definition file name: /frscript.php in /homepages/30/d593365489/htdocs/fpdf.php:271 Stack trace: #0 /homepages/30/d593365489/htdocs/fpdf.php(1142): FPDF->Error('Incorrect font ...') #1 /homepages/30/d593365489/htdocs/fpdf.php(459): FPDF->_loadfont('/frscript.php') #2 /homepages/30/d593365489/htdocs/Prnpdf.php(110): FPDF->AddFont('french script m...', '', '/frscript.php') #3 {main} thrown in /homepages/30/d593365489/htdocs/fpdf.php on line 271

What is also wierd even if I change the font it still reports the error with the French Script font?

Had a quick look at the font file, but can't see anything wrong.
I'm guessing there is a change in the frscript.php, but I am not knowledgable to spot it! Before the upgrade to 7.2 it was working OK.

Link to comment
https://forums.phpfreaks.com/topic/309156-problem-with-fpdf/#findComment-1569455
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.