SQLSTATE[HY000] [1049] Unknown database 'dbname'
Posted by: hasaneryilmaz0 (---.2.15.144.dynamic.ttnet.com.tr)
Date: March 14, 2020 08:49AM

Although I have a database, I get the following error.


SQLSTATE[HY000] [1049] Unknown database 'hascodin_site'



php connection code

>
		$baglanti = "mysql:host=localhost;dbname=hascodin_site";
		$mysqluser = "root";
		$mysqlpass = "";

	try{
		$baglan = new PDO($GLOBALS["baglanti"],$GLOBALS["mysqluser"],$GLOBALS["mysqlpass"]);
		$baglan->query("SET CHARACTER SET 'utf8'"winking smiley;
		$baglan->query("SET NAMES 'utf8'"winking smiley;
	}catch(PDOException $e){
		print $e->getMessage();
	}



<



Edited 1 time(s). Last edit at 03/16/2020 10:44AM by RiggsFolly.

Options: ReplyQuote
Re: SQLSTATE[HY000] [1049] Unknown database 'dbname'
Posted by: RiggsFolly (Moderator)
Date: March 16, 2020 10:47AM

Hi,

So WHY are you using `$GLOBALS["baglanti"]` rather than a simple

$baglan = new PDO($baglanti,$mysqluser,$mysqlpass);

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.2.0 32bit & 64bit)
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.19>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your MySQL databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote


Sorry, only registered users may post in this forum.