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.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

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 databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: SQLSTATE[HY000] [1049] Unknown database 'dbname'
Posted by: deepak_kikan (---.actcorp.in)
Date: July 14, 2020 06:23PM

as per stackoverflow site

[stackoverflow.com]

seems it is related to port issue in new wampserver which should be fixed.

Options: ReplyQuote
Re: SQLSTATE[HY000] [1049] Unknown database 'dbname'
Posted by: Otomatic (Moderator)
Date: July 14, 2020 06:49PM

Hi,

> seems it is related to port issue in new wampserver which should be fixed.
No, nothing has to be fixed in Wampserver 3, either the first or the last versions. It has to do with the fact that nobody reads what it is advised to read and does anything without knowing.

Right or Left Click -> Help -> MariaDB - MySQL

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote


Sorry, only registered users may post in this forum.