i'm new to PHP, so I might look silly here
Here's the question, I would like to instantiate a Database class, which creates a connection to a MySQL database, and nothing else (just trying things out)
Code: Select all
<?php
include("constants.inc");
include("Database.class.php");
$Database = new Database($DB_HOST , $USERNAME , $PW , $DBNAME);
?>This is database.class.php:
Code: Select all
<?php
class Database
{
var $DatabaseHost;
var $DatabaseUser;
var $DatabasePass;
var $DatabaseName;
function Database($1,$2,$3,$4)
{
$this->DatabaseHost = $1;
$this->DatabaseUser = $2;
$this->DatabasePass = $3;
$this->DatabaseName = $4;
$ServerConnection = mysql_pconnect( $this->DatabaseHost , $this->DatabaseUser , $this->DatabasePass
);
if ( !$ServerConnection )
{
echo( "Sorry, but a connection to the server could not be made " . mysql_error() );
}
$DatabaseConnection = mysql_select_db( $this->DatabaseName , $ServerConnection );
if ( !$DatabaseConnection )
{
echo( "Sorry, but a connection to the database could not be made " . mysql_error() );
}
}
}
?>Code: Select all
function Database($1,$2,$3,$4)Thanks in advance.