Php – require_once :failed to open stream error: no such file or directory

PHPrequire-once

$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

Best Answer

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');