Results 1 to 2 of 2

Thread: [RESOLVED] Undefined Variable

Threaded View

  1. #1

    Thread Starter
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416

    Resolved [RESOLVED] Undefined Variable

    Sorry to ask this n00b question.
    It's just my 2nd day in php.

    I have this class database connection:
    PHP Code:
    <?php
    class DBConnection{

    private 
    $link;

    public function 
    connect(){
    include 
    'connstring.php';
    $link mysql_connect($host,$user,$pw);
    if(!
    $link)
    {
        die(
    'Could not connect'.mysql_error());
    }
    }

    public function 
    close()
    {
        
    mysql_close($link);
    }
    }
    ?>
    But when I call connect and close function the errors come out.
    Notice: Undefined variable: link in C:\Program Files\Apache Group\Apache2\htdocs\connection.php on line 16

    Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource in C:\Program Files\Apache Group\Apache2\htdocs\connection.php on line 16
    why?

    edit: using
    PHP Code:
    $this->link 
    do the trick.
    Last edited by mar_zim; Feb 18th, 2006 at 04:11 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width