0
$conn = mysql_connect($servername,$dbusername,$dbpassword) or die(mysql_error());
mysql_select_db($dbname) or die ("could not open db".mysql_error());

require_once dirname('../tcpdf/config/lang/eng.php');
require_once dirname('../tcpdf/tcpdf.php');

error: Warning: require_once(../tcpdf/config/lang): failed to open stream: No such file or directory in C:\xampp\htdocs\jmb_system\anggerik\printunitstmt.php on line 33

Fatal error: require_once(): Failed opening required '../tcpdf/config/lang' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\jmb_s

Kindly where is the error? Thanks

Vic Seedoubleyew
  • 9,888
  • 6
  • 55
  • 76
Malvin Tan
  • 3
  • 1
  • 4
  • Possible duplicate of [Failed to open stream : No such file or directory](http://stackoverflow.com/questions/36577020/failed-to-open-stream-no-such-file-or-directory) – Vic Seedoubleyew Sep 10 '16 at 10:58

3 Answers3

0

dirname() gives you the path of the directory (in this case '../tcpdf/config/lang'). Require_once needs the file. Just remove the dirname().

require_once('../tcpdf/config/lang/eng.php');
require_once('../tcpdf/tcpdf.php');

or, if the "tcpdf" folder is in the same directory:

require_once('./tcpdf/config/lang/eng.php');
require_once('./tcpdf/tcpdf.php');
SalkinD
  • 753
  • 9
  • 23
  • hi salkin, after i have removed DIRNAME and the error still the same. it still pointing on the require_once line there. – Malvin Tan Dec 29 '14 at 15:32
  • then the path is wrong. is the 'tcpdf' folder in the same directory than your php script? Then remove the '../' from the path – SalkinD Dec 29 '14 at 15:35
  • is i doesn't have the eng.php and tcpdf.php? then how should i create out the code? – Malvin Tan Dec 29 '14 at 15:39
  • I assume u have downloaded tcpdf When you put the "tcpdf" folder at the same place like your php script the code would be "require_once('./tcpdf/tcpdf.php');" – SalkinD Dec 29 '14 at 15:41
  • yes i have. is it i need to put the tcpdf file together with my script or how? – Malvin Tan Dec 29 '14 at 15:48
  • there is a folder called "tcpdf". Put this one in the same directory than your php script, then require_once('./tcpdf/tcpdf.php'); works. – SalkinD Dec 29 '14 at 15:51
  • and something more: try removing the require_once('./tcpdf/config/lang/eng.php'); (keep only the require_once('./tcpdf/tcpdf.php'); ) as it seems this file is not included in standard download! – SalkinD Dec 29 '14 at 15:58
  • it's function already according what you have suggested. but the error right now pointing on this line of code "$pdf->setLanguageArray($l);" – Malvin Tan Dec 29 '14 at 17:04
  • this line seems to be optional. try to remove it. – SalkinD Dec 29 '14 at 17:23
  • OMG. it works so well, thanks for your kind guidance. – Malvin Tan Dec 29 '14 at 17:28
  • One often runs into this error, and to quickly troubleshoot it, follow these steps : http://stackoverflow.com/a/36577021/2873507 – Vic Seedoubleyew Apr 12 '16 at 17:00
0

Use something like

require_once dirname(__FILE__) . "/path/to/file";

where

dirname(__FILE__) 

means current file path. Very usefull for relative including. Don't forget the first slash

dirname('/../tcpdf/config/lang/eng.php');
0

Try:

$filename = realpath('../tcpdf/tcpdf.php');
var_dump($filename);

What does it return? If it returns bool(false), the path/file doesn't exist here.

Hafenkranich
  • 1,696
  • 18
  • 32