CodeIgniter Forums
Loading a library (works fine in native php) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Loading a library (works fine in native php) (/showthread.php?tid=25532)



Loading a library (works fine in native php) - El Forum - 12-15-2009

[eluser]deco10[/eluser]
I need to use a library (class) on my CI site. I use this class on other sites with no issues.

I renamed the files so they matched the name of the class in the file which gets CI to (try) and load them. It gives me a load of errors though (in this case an undefined index in the class)

Hopefully somebody can help me with this. If you have questions or need more info please ask Smile

Code:
$this->load->library("Cpdf");        
        $this->load->library("Cezpdf");        

        $pdf =& new Cezpdf();
        $pdf->selectFont('./fonts/Courier.afm');



Loading a library (works fine in native php) - El Forum - 12-15-2009

[eluser]jedd[/eluser]
[quote author="deco10" date="1260936314"]
I renamed the files so they matched the name of the class in the file which gets CI to (try) and load them. It gives me a load of errors though (in this case an undefined index in the class)
[/quote]

Show, rather than tell. Specifically, file name and location - and class declaration (inside the library) - and error message (verbatim).

The error - does it give a line number? Is it the load-> or the & new line in the controller, or an error within the library file?


Loading a library (works fine in native php) - El Forum - 12-15-2009

[eluser]deco10[/eluser]
Its an error within the library (index undefined)

system/application/libraries/Cezpdf.php
system/application/libraries/Cpdf.php

Code:
<?php

//This is the Cezpdf.php file
//Not sure how I should go about letting this include there.
include_once('Cpdf.php');

class Cezpdf extends Cpdf {




//This is the Cpdf.php file
<?php

class Cpdf {


the error (occurs several times):

A PHP Error was encountered

Severity: Notice

Message: Undefined index:

Filename: libraries/Cpdf.php

Line Number: 1631


Loading a library (works fine in native php) - El Forum - 12-15-2009

[eluser]deco10[/eluser]
This was the problem:

$pdf->selectFont('./fonts/Courier.afm')

changed it to

$pdf->selectFont('system/application/libraries/fonts/Courier.afm')