Mythic Fr0st Posted February 26, 2007 Share Posted February 26, 2007 I want to use _LINE_ to get the line of an error.. I get the error Notice: Use of undefined constant _LINE_ - assumed '_LINE_' in C:\Program Files\EasyPHP1-8\www\Main Files\Require Files\mysqlconnect.php on line 7 CODE: <?php $con = mysql_connect("localhost", "cheryl", "bubby"); if (!$con) { die('An error has occured, please retry in 30 minutes ['.mysql_error().']'); } mysql_select_db('an') or die("mysqlconnect "._LINE_); ?> I want it to die, then give me the line of the error... but it just gives errors\ So can anyone tell me how do I use it correctly? also im not sure if die() is the right command im using? is it? Link to comment https://forums.phpfreaks.com/topic/40106-solved-using-_line_-in-text-to-get-the-line-number-of-an-error/ Share on other sites More sharing options...
spfoonnewb Posted February 26, 2007 Share Posted February 26, 2007 Something like this should work: <?php function return_error($file, $line) { echo "An error occured in $file on line $line"; } $con = mysql_connect("localhost", "test", "test"); if (!$con) { die('An error has occured, please retry in 30 minutes ['.mysql_error().']'); } mysql_select_db('test') or die("".return_error(__FILE__, __LINE__).""); ?> Link to comment https://forums.phpfreaks.com/topic/40106-solved-using-_line_-in-text-to-get-the-line-number-of-an-error/#findComment-194044 Share on other sites More sharing options...
shoz Posted February 26, 2007 Share Posted February 26, 2007 You may also want to consider using trigger_error() Link to comment https://forums.phpfreaks.com/topic/40106-solved-using-_line_-in-text-to-get-the-line-number-of-an-error/#findComment-194047 Share on other sites More sharing options...
Mythic Fr0st Posted February 26, 2007 Author Share Posted February 26, 2007 Thanks guys, I'll look into that trigger error() a bit later... it works great ~ spfoonnewb Link to comment https://forums.phpfreaks.com/topic/40106-solved-using-_line_-in-text-to-get-the-line-number-of-an-error/#findComment-194063 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.