Jump to content

I can't get my classes to work (below) ? why ?


jd2007

Recommended Posts

<?php

/**
* @author 
* @copyright 2007
*/
include("connectdb.php");
class FlashProfile extends ConnectDB
{
  private $host;
  private $user;
  private $pass;
  private $db;
  private $table;
  private $title;
  private $id;
  private $author;
  private $subm;
  private $score;
  private $main;
  private $size;
  private $arr;
  private $i;
  private $que;
  private $res;
  private $row;

  function __construct($h, $u, $p, $d, $t, $i, $ti, $aut, $sub, $sc, $sz, $comm, $rec)
{
  parent::__construct;
      $this->host=$h;
  $this->user=$u;
  $this->pass=$p;
  $this->db=$d;
  $this->table=$t;
  $this->id=$i;
  $this->title=$ti;
  $this->author=$aut;
  $this->subm=$sub;
  $this->score=$sc;
  $this->size=$sz;
  $this->main=$comm;
  $this->recommended=$rec;
    }
/*
  function connectdb()
{
      mysql_connect($this->host, $this->user, $this->pass);
      mysql_select_db($this->db);
}
  */
  //parent::connectdb;
  function title()
  {
$this->que="select $this->title from $this->table where id='$this->id'";
$this->res=mysql_query($this->que);
$this->row=mysql_fetch_row($this->res);
echo $this->row[0];
  }
  
  function rightInfo()
  {
$this->que="select $this->author, $this->subm, $this->score, $this->size from $this->table where id='$this->id'";
$this->res=mysql_query($this->que);
$this->row=mysql_fetch_row($this->res);
$this->arr=array("Author", "Submitted", "Score", "Size");
$this->i=0;
foreach ($this->row as $info)
{	
  echo "<tr>
            <td class='style1'>".$this->arr[$this->i].": </td>
            <td class='style1'>".$info."</td>
          </tr>";
      $this->i++;    
}	
  }
  
  function authorComments()
  {
   	$this->que="select $this->main from $this->table where id='$this->id'";
$this->res=mysql_query($this->que);
$this->row=mysql_fetch_row($this->res);
echo "<tr>
            <td colspan='2'' bgcolor='#353535''><p class='style4'>".$this->row[0]."</p></td>
          </tr>";
  }
  
  function ageView()
  {
$this->que="select $this->recommended from $this->table where id='$this->id'";
$this->res=mysql_query($this->que);
$this->row=mysql_fetch_row($this->res);
echo "<td rowspan='2' class='style1'><div align='center'><img src='../images/icons/".$this->row[0]."' width='50' height='50' /></div></td>
            <td><span class='style2'>Recommended for: <b>".$this->row[0]."</b></span></td>
          </tr>";
  }
}



include("flashpageclass.php");
$profile=new FlashProfile("localhost", "root", "jd2008", "FlashPortal", "flash", 1, "title", "author", "submitted", "score", "size", "main", "recommended");
$profile->connectdb();
?>

 

parent class is in connectdb.php:

 

class ConnectDB
{
private $localhost;
private $user;
private $pass;
private $db;
private $con;
private $data;

function _construct($l, $u, $p, $d)
{
  $this->localhost=$l;
  $this->user=$u;
  $this->pass=$p;
  $this->db=$d;	
}

function connectdb()
{
  $this->con=mysql_connect($this->localhost, $this->user, $this->pass);
  $this->data=mysql_select_db($this->db, $this->con);	
}
}

Link to comment
https://forums.phpfreaks.com/topic/65240-i-cant-get-my-classes-to-work-below-why/
Share on other sites

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.