Php OOP woes

Soldato
Joined
4 Mar 2010
Posts
5,038
Hi guys having a bit of trouble with a couple of classes...

I am getting no errors caught nor a confirmation to say a connection was successful using PDO called in a class and it's becoming a little annoying. The connection details are being called from a static class; also no errors , it seems.

It just seems to fall asleep inside the classes as the </body></html> is not being output.

If I may I will do a code dump of the files in question, any help would be awesome!

Index.php
PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Display Names</title>
</head>

<body>



<?php

error_reporting(E_ALL);

require_once($_SERVER['DOCUMENT_ROOT']."/php/classes/display_names.php");

$display = new display_names(db_details::admin_user, db_details::admin_pass, db_details::hostname);

$display->connect();

?>

</body>

</html>

display_names.php
PHP:
<?php

/**
 * This class is used for getting usernames from the table 'oop'
 * 
 * db_details is required as it contains the user and pass needed to connect. 
 *
 * @author Lukie
 */
error_reporting(E_ALL);

require_once($_SERVER['DOCUMENT_ROOT']."/php/classes/db_details.php");
 
class display_names
{

	public $user;
	public $pass;
	public $hostname;
	
	
	
	public function __construct($user,$pass,$host)
	{
		
		$this->user = $user;
		
		$this->pass = $pass;
		
		$this->hostname = $host;		

	}
	
	public function connect()
	{
			
		try 
		
            
			$db = new PDO("mysql:host=$this->hostname;dbname=mysql", $this->user , $this->pass );
			echo 'sucess';
			
			
		}
		catch(PDOException $e)
		{
			
			echo $e->getMessage();
		}
	}
	




}
?>

db_details.php
PHP:
<?php

/**
 * This is a static class containing all the connection 
 * usernames and passwords needed for the database.
 * 
 * admin has open access to all tables while general has no writeible permissions and only access to articles table. 
 *
 * @author Lukie
 */
error_reporting(E_ALL);

class db_details
{
	
	static public $admin_user = 'root';
	
	static public $admin_pass = '';
		
	static public $general_user = '';
		
	static public $general_pass = '';
	
	static public $hostname = 'localhost';
			
}
		
		
?>
 
Back
Top Bottom