PHP interesse |
|
hey,
ik heb deze class gemaakt:
class media {
public $sQuery;
public function getConnection($host,$usr,$password) {
mysql_connect($host,$usr,$password) or die('error: "'.mysql_error().'"');
mysql_select_db('media') or die('error: "database \'media\' not found"');
}
public function getMedia($sMediaTitle) {
$sQuery = "SELECT * FROM media WHERE media_title = '" .mysql_real_escape_string($media_title). "'";
$qpQuery = mysql_query($sQuery) or die('error: "'.mysql_error().'"');
while($data = mysql_fetch_assoc($qpQuery)) {
print_r($data);
}
}
}
class media { public $sQuery; public function getConnection($host,$usr,$password) { } public function getMedia($sMediaTitle) { } } }
en vervolgens deze code:
include('media.class.php');
$media = new media;
$media->getConnection('localhost','*************','*******');
$media->getMedia('een title');
include('media.class.php'); $media = new media; $media->getConnection('localhost','*************','*******'); $media->getMedia('een title');
nu wordt er helemaal niks geselecteerd uit de database, maar er staat wel wat in de database.
|