Jump to content

Mysql error with a simple class. Easy answer but im an oop n00b


AbydosGater

Recommended Posts

Hey im sorry, Im sure there is a simple answer to this but im a n00b to oop. And ive been working on a simple page creation script for about the last 20 minutes haha.

Right to the point. Im using the code...

 

<?php
class CreatePage{ //Initialize The Class

//Variable Setup
var $title;
var $navlinks;
var $rightnav;
var $footer;
var $dbuser;
var $dbpass;
var $dbname;
//End Variable Setup

//Function Creation
function __construct($title){
//Constructor
$page->title = $title;
$page->dbuser = "stargate_admin";
$page->dbpass = "iolar84";
$page->dbname = "stargate_system";
}

function dbconnect(){
mysql_connect("localhost", $page->dbuser, $page->dbpass);
mysql_select_db($page->dbname);
}

} //Closing The Class

$thePage = new CreatePage("Andys Page");
$thePage->dbconnect();
?>

 

I know its not much. But how do i get the variables to go into the mysql_connect cause im getting errors about there being noone as a username so its no printing the variable for user and pass there.

 

Could someone please help?

 

Andy

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.