SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Mar 2006
    Posts
    701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem with class

    I have a problem with this code
    Code:
    <?php
    class Mypdo
    {  static $dbh;
       public static function mydbh()
    { if (self::dbh==null)
        {     self::dbh  = new PDO("mysql:host=localhost;dbname=auctions", "dimis", "dimis");}
    return self::dbh;
    }
    }
    ?>
    Parse error: syntax error, unexpected '=' on line 6
    What is wrong?

  2. #2
    SitePoint Addict
    Join Date
    Dec 2005
    Posts
    336
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Code:
    self::dbh
    should be
    Code:
    self::$dbh

  3. #3
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    69 Post(s)
    Tagged
    0 Thread(s)
    you forgot the $ in front of dbh?

    EDIT: Yay for slow posting in the mornings, beaten again ;P


Bookmarks

Posting Permissions

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