SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard davidjmedlock's Avatar
    Join Date
    Dec 2002
    Location
    Nashville, TN USA
    Posts
    1,688
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Passing object won't work

    Okay, maybe I'm totally nuts, but shouldn't this work:

    PHP Code:
    include("config.php");
    include(
    "DatabaseManager.php");
    include(
    "ContentManager.php");
    $dbmgr = new DatabaseManager($dbServer$dbUsername$dbPassword$dbName);
    echo ( 
    "DatabaseManager dbmgr created." );
    $cnmgr = new ContentManager($dbmgr); 
    Here's the ContentManager code

    PHP Code:
    class ContentManager() {
        var 
    $dbmgr;
        
        function 
    ContentManager($dbmgr) {
            
    $this->dbmgr $dbmgr;
        }
        
        function 
    retrieveContent($contentName$contentType) {
            
    $sql "SELECT * FROM content";
            
            if (
    $contentType == 'ID') {
                
    $sql "SELECT * FROM content WHERE content_id = " $contentName;
            }
            else {
                
    $sql "SELECT * FROM content WHERE content_type = '" $contentName "'";
            }
            
            if ( !
    $results ) {
                echo ( 
    "Could not return results" );
                
    $results "";
            }
            
            
    $results $this->dbmgr->runQuery($sql);
            
            return 
    $results;
        }

    Can anybody tell me why this isn't working? it apparently stops executing where I create $cnmgr. (I don't have any debug settings or error message display on my server )

  2. #2
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    class ContentManager() {

    remove the ().
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  3. #3
    SitePoint Wizard davidjmedlock's Avatar
    Join Date
    Dec 2002
    Location
    Nashville, TN USA
    Posts
    1,688
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Excellent catch... I can't believe I didn't see that myself. Thanks Jeff!!


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
  •