[SOLVED] OOP
Posted: Thu Mar 10, 2005 4:01 pm
can somebody help me out with this code, when I open the file, it shows a blank white page (no links) I asked a guy that was really good with php and he had no clue what was wrong with it either...
Code: Select all
<?php
//Start class Template
class template {
//Define class variables
var $tblinks,
$linkname,
$linkurl,
$linkid,
$sqluser,
$sqlpass,
$sqldb,
$sqlhost;
//Start Links Function
function Links(){
$this->sqluser = 'root';
$this->sqlpass = '';
$this->sqldb = 'portal';
$this->sqlhost = 'localhost';
$this->tblinks = 'links';
$dbcnx = @mysql_connect($this->sqlhost,$this->sqluser,$this->sqlpass);
if(!$dbcnx) {
echo( 'Could not connect to the MySQL server' );
}
mysql_select_db($this->sqldb);
$get_links = mysql_query("SELECT ID, Name, URL FROM $this->tblinks");
// Get Links From Database
while ($link_data = mysql_fetch_array($get_links)) {
$this->linkid = $link_data['ID'];
$this->linkname = $link_data['Name'];
$this->linkurl = $link_data['URL'];
//Display Links
echo("<br><a href=$url>$name</a>");
}
//Set new variable
$SiteLinks = new template;
$Links = $SiteLinks->Links();
}
}
//End Class Template
?>
<?=$Links;?>