Account Maker Problem z baza danych

Status
Zamknięty.

LubiePlacki100

Advanced User
Zarejestrowany
Dołączył
Grudzień 25, 2010
Posty
182
Liczba reakcji
1
Cze?c, od wczoraj nie moge po??czy? sie z baza danych i og?lnie mam problem wyskakuje takie co? gdy chce wej?? na strone.

Error occured!
Error ID:
More info: CANNOT CONNECT TO DATABASE: SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (10061)

File: D:\xampp\htdocs\classes/database_mysql.php Line: 22
File: D:\xampp\htdocs\classes/database.php Line: 199
File: D:\xampp\htdocs\pages/latestnews.php Line: 15
File: D:\xampp\htdocs\system/load.page.php Line: 7
File: D:\xampp\htdocs/index.php Line: 37



File: D:\xampp\htdocs\classes/database_mysql.php Line: 22
PHP:
<?php
if(!defined('INITIALIZED'))
	exit;

class Database_MySQL extends Database
{
	public function __construct()
	{
		$this->setDatabaseDriver(self::DB_MYSQL);
	}

	public function connect()
	{
		try
		{
			parent::__construct('mysql:host=' . $this->getDatabaseHost() . ';port=' . $this->getDatabasePort() . ';dbname=' . $this->getDatabaseName(), $this->getDatabaseUsername(), $this->getDatabasePassword());
			$this->setConnected(true);
			return true;
		}
		catch(PDOException $error)
		{
			new Error_Critic('', 'CANNOT CONNECT TO DATABASE: ' . $error->getMessage());
			return false;
		}
	}

	public function fieldName($name)
	{
		if(strspn($name, "1234567890qwertyuiopasdfghjklzxcvbnm_") != strlen($name))
			new Error_Critic('', 'Invalid field name format.');

		return '`' . $name . '`';
	}

	public function tableName($name)
	{
		if(strspn($name, "1234567890qwertyuiopasdfghjklzxcvbnm_") != strlen($name))
			new Error_Critic('', 'Invalid table name format.');

		return '`' . $name . '`';
	}
}


File: D:\xampp\htdocs\classes/database.php Line: 199
PHP:
<?php
if(!defined('INITIALIZED'))
	exit;

class Database extends PDO
{
	public $connectionError = '';
	private $connected = false;
	const DB_MYSQL = 1;
	const DB_SQLITE = 2;
	const DB_PGSQL = 3;

	private $db_driver;
	private $db_host = 'localhost';
	private $db_port = '3306';
	private $db_name;
	private $db_username;
	private $db_password;
	private $db_file;

	public $queriesCount = 0;
	public $printQueries = false;

	public function connect()
	{
		return false;
	}

	public function isConnected()
	{
		return $this->connected;
	}

	public function setPrintQueries($value)
	{
		return $this->printQueries = $value;
	}

	public function setConnected($value)
	{
		$this->connected = $value;
	}

	public function getDatabaseDriver()
	{
		return $this->db_driver;
	}

	public function getDatabaseHost()
	{
		return $this->db_host;
	}

	public function getDatabasePort()
	{
		return $this->db_port;
	}

	public function getDatabaseName()
	{
		return $this->db_name;
	}

	public function getDatabaseUsername()
	{
		return $this->db_username;
	}

	public function getDatabasePassword()
	{
		return $this->db_password;
	}

	public function getDatabaseFile()
	{
		return $this->db_file;
	}

	public function setDatabaseDriver($value)
	{
		$this->db_driver = $value;
	}

	public function setDatabaseHost($value)
	{
		$this->db_host = $value;
	}

	public function setDatabasePort($value)
	{
		$this->db_port = $value;
	}

	public function setDatabaseName($value)
	{
		$this->db_name = $value;
	}

	public function setDatabaseUsername($value)
	{
		$this->db_username = $value;
	}

	public function setDatabasePassword($value)
	{
		$this->db_password = $value;
	}

	public function setDatabaseFile($value)
	{
		$this->db_file = $value;
	}

	public function beginTransaction()
	{
		if($this->isConnected() || $this->connect())
			return parent::beginTransaction();
		else
			new Error_Critic('', 'Website is not connected to database. Cannot execute "beginTransaction()"');
	}

	public function commit()
	{
		if($this->isConnected() || $this->connect())
			return parent::commit();
		else
			new Error_Critic('', 'Website is not connected to database. Cannot execute "commit()"');
	}

	public function errorCode()
	{
		if($this->isConnected() || $this->connect())
			return parent::errorCode();
		else
			new Error_Critic('', 'Website is not connected to database. Cannot execute "errorCode()"');
	}

	public function errorInfo()
	{
		if($this->isConnected() || $this->connect())
			return parent::errorInfo();
		else
			new Error_Critic('', 'Website is not connected to database. Cannot execute errorInfo()');
	}

	public function exec($statement)
	{
		if($this->isConnected() || $this->connect())
			return parent::exec($statement);
		else
			new Error_Critic('', 'Website is not connected to database. Cannot execute exec($statement)');
	}

	public function getAttribute($attribute)
	{
		if($this->isConnected() || $this->connect())
			return parent::getAttribute($attribute);
		else
			new Error_Critic('', 'Website is not connected to database. Cannot execute getAttribute($attribute)');
	}

	public static function getAvailableDrivers()
	{
		if($this->isConnected() || $this->connect())
			return parent::getAvailableDrivers();
		else
			new Error_Critic('', 'Website is not connected to database. Cannot execute getAvailableDrivers()');
	}

	public function inTransaction()
	{
		if($this->isConnected() || $this->connect())
			return parent::inTransaction();
		else
			new Error_Critic('', 'Website is not connected to database. Cannot execute inTransaction()');
	}

	public function lastInsertId($name = NULL)
	{
		if($this->isConnected() || $this->connect())
			return parent::lastInsertId($name);
		else
			new Error_Critic('', 'Website is not connected to database. Cannot execute ');
	}

	public function prepare($statement, $driver_options = array())
	{
		if($this->isConnected() || $this->connect())
			return parent::prepare($statement, $driver_options);
		else
			new Error_Critic('', 'Website is not connected to database. Cannot execute lastInsertId($name)');
	}

	public function query($statement)
	{
		$this->queriesCount++;
		// BETA TESTS - uncomment line below to print all queries on website before execution
		//echo'<br />' . $statement . '<br />';
		if($this->isConnected() || $this->connect())
		{
			$ret = parent::query($statement);
			if($this->printQueries)
			{
				$_errorInfo = $this->errorInfo();
				echo '<table>';
				echo '<tr><td>Query: </td><td>' . $statement . '</td></tr>';
				echo '<tr><td>SQLSTATE: </td><td>' . $_errorInfo[0] . '</td></tr>';
				echo '<tr><td>Driver code: </td><td>' . $_errorInfo[1] . '</td></tr>';
				echo '<tr><td>Error message: </td><td>' . $_errorInfo[2] . '</td></tr>';
				echo '</table>';
			}
			return $ret;
		}
		else
			new Error_Critic('', 'Website is not connected to database. Cannot execute query($statement)');
	}

	public function quote($string, $parameter_type = PDO::PARAM_STR)
	{
		if($this->isConnected() || $this->connect())
			return parent::quote($string, $parameter_type);
		else
			new Error_Critic('', 'Website is not connected to database. Cannot execute quote($string, $parameter_type)');
	}

	public function rollBack()
	{
		if($this->isConnected() || $this->connect())
			return parent::rollBack();
		else
			new Error_Critic('', 'Website is not connected to database. Cannot execute rollBack()');
	}

	public function setAttribute($attribute, $value)
	{
		if($this->isConnected() || $this->connect())
			return parent::setAttribute($attribute, $value);
		else
			new Error_Critic('', 'Website is not connected to database. Cannot execute setAttribute($attribute, $value)');
	}

	public function setConnectionError($string)
	{
		$this->connectionError = $string;
	}
}

File: D:\xampp\htdocs\pages/latestnews.php Line: 15
PHP:
<?php
if(!defined('INITIALIZED'))
	exit;

// top kills - guilds
$main_content .= '<table border="0" width="100%">
	<tr>
		<td style="text-align: center; font-weight: bold;">
			<center><font color="red">Most powerfull guilds</font></center>
		</td>
	</tr>
</table>';

$main_content .= '<table border="0" cellspacing="3" cellpadding="4" width="100%"><tr>';
foreach($SQL->query('SELECT ' . $SQL->tableName('g') . '.' . $SQL->fieldName('id') . ' AS ' . $SQL->fieldName('id') . ', ' . $SQL->tableName('g') . '.' . $SQL->fieldName('name') . ' AS ' . $SQL->fieldName('name') . ', COUNT(' . $SQL->tableName('g') . '.' . $SQL->fieldName('name') . ') AS ' . $SQL->fieldName('frags') . ' FROM ' . $SQL->tableName('killers') . ' k LEFT JOIN ' . $SQL->tableName('player_killers') . ' pk ON ' . $SQL->tableName('k') . '.' . $SQL->fieldName('id') . ' = ' . $SQL->tableName('pk') . '.' . $SQL->fieldName('kill_id') . ' LEFT JOIN ' . $SQL->tableName('players') . ' p ON ' . $SQL->tableName('pk') . '.' . $SQL->fieldName('player_id') . ' = ' . $SQL->tableName('p') . '.' . $SQL->fieldName('id') . ' LEFT JOIN ' . $SQL->tableName('guild_ranks') . ' gr ON ' . $SQL->tableName('p') . '.' . $SQL->fieldName('rank_id') . ' = ' . $SQL->tableName('gr') . '.' . $SQL->fieldName('id') . ' LEFT JOIN ' . $SQL->tableName('guilds') . ' g ON ' . $SQL->tableName('gr') . '.' . $SQL->fieldName('guild_id') . ' = ' . $SQL->tableName('g') . '.' . $SQL->fieldName('id') . ' WHERE ' . $SQL->tableName('g') . '.' . $SQL->fieldName('id') . ' > 0 AND ' . $SQL->tableName('k') . '.' . $SQL->fieldName('unjustified') . ' = 1 AND ' . $SQL->tableName('k') . '.' . $SQL->fieldName('final_hit') . ' = 1 GROUP BY ' . $SQL->fieldName('name') . ' ORDER BY ' . $SQL->fieldName('frags') . ' DESC, ' . $SQL->fieldName('name') . ' ASC LIMIT 4;') as $guild)
$main_content .= '<td style="width: 25%; text-align: center;"><a href="?subtopic=guilds&action=show&guild=' . $guild['id'] . '"><img src="guild_image.php?id=' . $guild['id'] . '" width="64" height="64" border="0"/><br />' . htmlspecialchars($guild['name']) . '</a><br />' . $guild['frags'] . ' kills
</td>';
$main_content .= '</tr></table>';





function replaceSmile($text, $smile)
{
    $smileys = array(';D' => 1, ':D' => 1, ':cool:' => 2, ';cool;' => 2, ':ekk:' => 3, ';ekk;' => 3, ';o' => 4, ';O' => 4, ':o' => 4, ':O' => 4, ':(' => 5, ';(' => 5, ':mad:' => 6, ';mad;' => 6, ';rolleyes;' => 7, ':rolleyes:' => 7, ':)' => 8, ';d' => 9, ':d' => 9, ';)' => 10);
    if($smile == 1)
        return $text;
    else
    {
        foreach($smileys as $search => $replace)
            $text = str_replace($search, '<img src="images/forum/smile/'.$replace.'.gif" />', $text);
        return $text;
    }
}

function replaceAll($text, $smile)
{
    $rows = 0;
    while(stripos($text, '[code]') !== false && stripos($text, '[/code]') !== false )
    {
        $code = substr($text, stripos($text, '[code]')+6, stripos($text, '[/code]') - stripos($text, '[code]') - 6);
        if(!is_int($rows / 2)) { $bgcolor = 'ABED25'; } else { $bgcolor = '23ED25'; } $rows++;
        $text = str_ireplace('[code]'.$code.'[/code]', '<i>Code:</i><br /><table cellpadding="0" style="background-color: #'.$bgcolor.'; width: 480px; border-style: dotted; border-color: #CCCCCC; border-width: 2px"><tr><td>'.$code.'</td></tr></table>', $text);
    }
    $rows = 0;
    while(stripos($text, '[quote]') !== false && stripos($text, '[/quote]') !== false )
    {
        $quote = substr($text, stripos($text, '[quote]')+7, stripos($text, '[/quote]') - stripos($text, '[quote]') - 7);
        if(!is_int($rows / 2)) { $bgcolor = 'AAAAAA'; } else { $bgcolor = 'CCCCCC'; } $rows++;
        $text = str_ireplace('[quote]'.$quote.'[/quote]', '<table cellpadding="0" style="background-color: #'.$bgcolor.'; width: 480px; border-style: dotted; border-color: #007900; border-width: 2px"><tr><td>'.$quote.'</td></tr></table>', $text);
    }
    $rows = 0;
    while(stripos($text, '[url]') !== false && stripos($text, '[/url]') !== false )
    {
        $url = substr($text, stripos($text, '[url]')+5, stripos($text, '[/url]') - stripos($text, '[url]') - 5);
        $text = str_ireplace('[url]'.$url.'[/url]', '<a href="'.$url.'" target="_blank">'.$url.'</a>', $text);
    }
    while(stripos($text, '[player]') !== false && stripos($text, '[/player]') !== false )
    {
        $player = substr($text, stripos($text, '[player]')+8, stripos($text, '[/player]') - stripos($text, '[player]') - 8);
        $text = str_ireplace('[player]'.$player.'[/player]', '<a href="?subtopic=characters&name='.urlencode($player).'">'.$player.'</a>', $text);
    }
    while(stripos($text, '[img]') !== false && stripos($text, '[/img]') !== false )
    {
        $img = substr($text, stripos($text, '[img]')+5, stripos($text, '[/img]') - stripos($text, '[img]') - 5);
        $text = str_ireplace('[img]'.$img.'[/img]', '<img src="'.$img.'">', $text);
    }
    while(stripos($text, '[b]') !== false && stripos($text, '[/b]') !== false )
    {
        $b = substr($text, stripos($text, '[b]')+3, stripos($text, '[/b]') - stripos($text, '[b]') - 3);
        $text = str_ireplace('[b]'.$b.'[/b]', '<b>'.$b.'</b>', $text);
    }
    while(stripos($text, '[i]') !== false && stripos($text, '[/i]') !== false )
    {
        $i = substr($text, stripos($text, '[i]')+3, stripos($text, '[/i]') - stripos($text, '[i]') - 3);
        $text = str_ireplace('[i]'.$i.'[/i]', '<i>'.$i.'</i>', $text);
    }
    while(stripos($text, '[u]') !== false && stripos($text, '[/u]') !== false )
    {
        $u = substr($text, stripos($text, '[u]')+3, stripos($text, '[/u]') - stripos($text, '[u]') - 3);
        $text = str_ireplace('[u]'.$u.'[/u]', '<u>'.$u.'</u>', $text);
    }
    return replaceSmile($text, $smile);
}

function showPost($topic, $text, $smile)
{
    $text = nl2br($text);
    $post = '';
    if(!empty($topic))
        $post .= '<b>'.replaceSmile($topic, $smile).'</b>';
    $post .= replaceAll($text, $smile);
    return $post;
}


    $last_threads = $SQL->query('SELECT ' . $SQL->tableName('players') . '.' . $SQL->fieldName('name') . ', ' . $SQL->tableName('z_forum') . '.' . $SQL->fieldName('post_text') . ', ' . $SQL->tableName('z_forum') . '.' . $SQL->fieldName('post_topic') . ', ' . $SQL->tableName('z_forum') . '.' . $SQL->fieldName('post_smile') . ', ' . $SQL->tableName('z_forum') . '.' . $SQL->fieldName('id') . ', ' . $SQL->tableName('z_forum') . '.' . $SQL->fieldName('replies') . ', ' . $SQL->tableName('z_forum') . '.' . $SQL->fieldName('post_date') . ' FROM ' . $SQL->tableName('players') . ', ' . $SQL->tableName('z_forum') . ' WHERE ' . $SQL->tableName('players') . '.' . $SQL->fieldName('id') . ' = ' . $SQL->tableName('z_forum') . '.' . $SQL->fieldName('author_guid') . ' AND ' . $SQL->tableName('z_forum') . '.' . $SQL->fieldName('section') . ' = 1 AND ' . $SQL->tableName('z_forum') . '.' . $SQL->fieldName('first_post') . ' = ' . $SQL->tableName('z_forum') . '.' . $SQL->fieldName('id') . ' ORDER BY ' . $SQL->tableName('z_forum') . '.' . $SQL->fieldName('last_post') . ' DESC LIMIT ' . $config['site']['news_limit'])->fetchAll();
    if(isset($last_threads[0]))
    {
        $main_content .= '<table width="100%">';
        foreach($last_threads as $thread)
        {
            $main_content .= '<tr><td><b>' . htmlspecialchars($thread['post_topic']) . '</a></td><td style="text-align:right">' . date('d.m.y H:i:s', $thread['post_date']) . '</td></tr>';
            $main_content .= '<tr><td colspan="2">' . showPost('', $thread['post_text'], $thread['post_smile']) . '</td></tr>';
			$main_content .= '<tr><td>by <a href="?subtopic=characters&name='. urlencode($thread['name']) .'">'. htmlspecialchars($thread['name']) .'</a></td><td style="text-align:right"><a href="?subtopic=forum&action=show_thread&id=' . $thread['id'] . '">[Comments: ' . $thread['replies'] . ']</a></td></tr>';
			$main_content .= '<tr style="background-color:black;width:100%;height:3px"><td colspan="2"></td></tr>';
        }
        $main_content .= '</table>';
    }
    else
        $main_content .= '<h3>No news. Go forum and make new thread on board News.</h3>';


File: D:\xampp\htdocs\system/load.page.php Line: 7
PHP:
<?php
if(!defined('INITIALIZED'))
	exit;

ob_start();
$main_content = '';
include("pages/" . $subtopic . ".php");
$main_content .= ob_get_clean();


File: D:\xampp\htdocs/index.php Line: 37
PHP:
<?php
// comment to show E_NOTICE [undefinied variable etc.], comment if you want make script and see all errors
error_reporting(E_ALL ^ E_STRICT ^ E_NOTICE);

// true = show sent queries and SQL queries status/status code/error message
define('DEBUG_DATABASE', false);

define('INITIALIZED', true);

// if not defined before, set 'false' to load all normal
if(!defined('ONLY_PAGE'))
	define('ONLY_PAGE', false);
	
// check if site is disabled/requires installation
include_once('./system/load.loadCheck.php');

// fix user data, load config, enable class auto loader
include_once('./system/load.init.php');

// DATABASE
include_once('./system/load.database.php');
if(DEBUG_DATABASE)
	Website::getDBHandle()->setPrintQueries(true);
// DATABASE END

// LOGIN
if(!ONLY_PAGE)
	include_once('./system/load.login.php');
// LOGIN END

// COMPAT
// some parts in that file can be blocked because of ONLY_PAGE constant
include_once('./system/load.compat.php');
// COMPAT END

// LOAD PAGE
include_once('./system/load.page.php');
// LOAD PAGE END

// LAYOUT
// with ONLY_PAGE we return only page text, not layout
if(!ONLY_PAGE)
	include_once('./system/load.layout.php');
else
	echo $main_content;
// LAYOUT END



@@@@ EDIT EDIT


Teraz wszystko odpali?o i wyskoczy? taki b??d tylko przy logowaniu do bazy danych

phpMyAdmin - B??d

Nie uda?o si? bezb??dnie utworzy? sesji. Nale?y sprawdzi? b??dy w logach PHP i serwera WWW, a nast?pnie w?a?ciwie skonfigurowa? instalacj? PHP.
 
Status
Zamknięty.
Back
Do góry