Jump to content

[SOLVED] using _LINE_ in text to get the line number of an error


Mythic Fr0st

Recommended Posts

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?

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__)."");

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.