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 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

------------------------------------------------------------------------------------------------------------
Wampserver 3.2.3 32 bit - Apache 2.4.46 - PHP 7.4.9…5.6.40 - MySQL 5.7.31 - MariaDB 10.5.4
Wampserver 3.2.3 64 bit - Apache 2.4.46 - PHP 7.4.9…5.6.40 - MySQL 5.7.31/8.0.21 - MariaDB 10.5.4
PhPMyadmin 5.0.2 - MysqlDumper 1.24.5
on W10 and W7 Pro 64 bit
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons
« Ce n'est pas parce qu'ils sont nombreux à avoir tort, qu'ils ont forcément raison. Coluche »
« It's not because they are many to be wrong, they are necessarily right. Coluche »

Options: ReplyQuote


Sorry, only registered users may post in this forum.