G'day to all,
Just learning about classes in PHP. A couple of the methods I hold within a class call upon connecting to a database. Would it be better to use an include() function like this:
Many thanks in advance,PHP Code:<?php
function registerUser($userName, $userPassword) {
# connect to database
include('dbsignup.php');
# select database
mysql_select_db($this->dbName);
# Code continues...
?>
or do I maintain using this:
PHP Code:<?php
function registerUser($userName, $userPassword) {
# connect to database
$dbLink = mysql_connect($this->dbHost, $this->dbUser, $this->dbPass);
if(!dbLink) die("Could not connect to database. " . mysql_error());
# select database
mysql_select_db($this->dbName);
# Code continues...
?>









Bookmarks