Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Dec 2007
    Posts
    269
    Thanks
    28
    Thanked 0 Times in 0 Posts

    error function does not run for mysql

    why doesnot this function run (erro message i have defined does not occur)

    PHP Code:
    ini_set('display_errors'false);
    function 
    db_error($no){
        
    "Error No :".$no."<br/>"."Error :".mysql_error();
        }
        
    $link mysql_connect('localhost''root''12');
    if (!
    $link) {
        die( 
    db_error(mysql_errno()));
    }
    echo 
    'Connected successfully';
    mysql_close($link); 

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    Because the error function isn't returning anything to die():
    PHP Code:
    function db_error($no)
    {
        return 
    'Error No : ' $no '<br/>Error : ' mysql_error();

    You don't really need a function for this simple code, by the way. You could just place the code(replace $no with mysql_error()) in the error function inside of the die();

  • Users who have thanked Inigoesdr for this post:

    zodehala (01-05-2008)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •