Error: SQLSTATE[HY000] [1049] Unknown database
up vote
0
down vote
favorite
I've been working on some beginner php exercise recently and have encountered an error to which I have no idea what is causing it.
It says
"Error: SQLSTATE[HY000] [1049] Unknown database 'otkrica'"
The sql file is correctly named "otkrica" and my db.php looks like this:
<?php
$dsn = "mysql:host=127.0.0.1;charset=utf8;dbname=otkrica";
try{
$pdo = new PDO($dsn,"root","");
}catch(PDOException $e){
die("Error: " . $e->getMessage());
}
?>
I would really appreciate input on this one. What am I missing?
php mysql pdo
add a comment |
up vote
0
down vote
favorite
I've been working on some beginner php exercise recently and have encountered an error to which I have no idea what is causing it.
It says
"Error: SQLSTATE[HY000] [1049] Unknown database 'otkrica'"
The sql file is correctly named "otkrica" and my db.php looks like this:
<?php
$dsn = "mysql:host=127.0.0.1;charset=utf8;dbname=otkrica";
try{
$pdo = new PDO($dsn,"root","");
}catch(PDOException $e){
die("Error: " . $e->getMessage());
}
?>
I would really appreciate input on this one. What am I missing?
php mysql pdo
2
Have you actually created a database namedotkrica?
– eggyal
Sep 1 '16 at 17:58
be sure you don't have more then one mysql installation. Try to set the port you are using like:mysql:host=localhost;port=3307;dbname=testdb
– cmnardi
Sep 1 '16 at 18:03
Yes, I did. It's in my project root folder and db.php is in root/core folder.
– Strahinjatronic
Sep 1 '16 at 18:05
this is not what i said. see in your database client the port of your mysql server instalation, and set it in your 'dsn' string
– cmnardi
Sep 1 '16 at 18:08
That did it. Thank you!
– Strahinjatronic
Sep 1 '16 at 19:06
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I've been working on some beginner php exercise recently and have encountered an error to which I have no idea what is causing it.
It says
"Error: SQLSTATE[HY000] [1049] Unknown database 'otkrica'"
The sql file is correctly named "otkrica" and my db.php looks like this:
<?php
$dsn = "mysql:host=127.0.0.1;charset=utf8;dbname=otkrica";
try{
$pdo = new PDO($dsn,"root","");
}catch(PDOException $e){
die("Error: " . $e->getMessage());
}
?>
I would really appreciate input on this one. What am I missing?
php mysql pdo
I've been working on some beginner php exercise recently and have encountered an error to which I have no idea what is causing it.
It says
"Error: SQLSTATE[HY000] [1049] Unknown database 'otkrica'"
The sql file is correctly named "otkrica" and my db.php looks like this:
<?php
$dsn = "mysql:host=127.0.0.1;charset=utf8;dbname=otkrica";
try{
$pdo = new PDO($dsn,"root","");
}catch(PDOException $e){
die("Error: " . $e->getMessage());
}
?>
I would really appreciate input on this one. What am I missing?
php mysql pdo
php mysql pdo
edited Sep 1 '16 at 17:57
Qirel
9,54862337
9,54862337
asked Sep 1 '16 at 17:56
Strahinjatronic
614
614
2
Have you actually created a database namedotkrica?
– eggyal
Sep 1 '16 at 17:58
be sure you don't have more then one mysql installation. Try to set the port you are using like:mysql:host=localhost;port=3307;dbname=testdb
– cmnardi
Sep 1 '16 at 18:03
Yes, I did. It's in my project root folder and db.php is in root/core folder.
– Strahinjatronic
Sep 1 '16 at 18:05
this is not what i said. see in your database client the port of your mysql server instalation, and set it in your 'dsn' string
– cmnardi
Sep 1 '16 at 18:08
That did it. Thank you!
– Strahinjatronic
Sep 1 '16 at 19:06
add a comment |
2
Have you actually created a database namedotkrica?
– eggyal
Sep 1 '16 at 17:58
be sure you don't have more then one mysql installation. Try to set the port you are using like:mysql:host=localhost;port=3307;dbname=testdb
– cmnardi
Sep 1 '16 at 18:03
Yes, I did. It's in my project root folder and db.php is in root/core folder.
– Strahinjatronic
Sep 1 '16 at 18:05
this is not what i said. see in your database client the port of your mysql server instalation, and set it in your 'dsn' string
– cmnardi
Sep 1 '16 at 18:08
That did it. Thank you!
– Strahinjatronic
Sep 1 '16 at 19:06
2
2
Have you actually created a database named
otkrica?– eggyal
Sep 1 '16 at 17:58
Have you actually created a database named
otkrica?– eggyal
Sep 1 '16 at 17:58
be sure you don't have more then one mysql installation. Try to set the port you are using like:
mysql:host=localhost;port=3307;dbname=testdb– cmnardi
Sep 1 '16 at 18:03
be sure you don't have more then one mysql installation. Try to set the port you are using like:
mysql:host=localhost;port=3307;dbname=testdb– cmnardi
Sep 1 '16 at 18:03
Yes, I did. It's in my project root folder and db.php is in root/core folder.
– Strahinjatronic
Sep 1 '16 at 18:05
Yes, I did. It's in my project root folder and db.php is in root/core folder.
– Strahinjatronic
Sep 1 '16 at 18:05
this is not what i said. see in your database client the port of your mysql server instalation, and set it in your 'dsn' string
– cmnardi
Sep 1 '16 at 18:08
this is not what i said. see in your database client the port of your mysql server instalation, and set it in your 'dsn' string
– cmnardi
Sep 1 '16 at 18:08
That did it. Thank you!
– Strahinjatronic
Sep 1 '16 at 19:06
That did it. Thank you!
– Strahinjatronic
Sep 1 '16 at 19:06
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
Create a new Database in phpMyAdmin with the same name of the database (otkrica.sql) file.
Select that database while Importing. Thank you.
New Database section in phpMyAdmin
add a comment |
up vote
0
down vote
I fix this problem wait this way
enter image description here
attention: use as wampserver ver2.5 for build database in the server
after run wampserver, click left on the icon in notify bar and then click on phpmyadmin and create the database.
1
Do not post images as an answer to the question.
– Vineeth Sai
Nov 11 at 7:48
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Create a new Database in phpMyAdmin with the same name of the database (otkrica.sql) file.
Select that database while Importing. Thank you.
New Database section in phpMyAdmin
add a comment |
up vote
0
down vote
Create a new Database in phpMyAdmin with the same name of the database (otkrica.sql) file.
Select that database while Importing. Thank you.
New Database section in phpMyAdmin
add a comment |
up vote
0
down vote
up vote
0
down vote
Create a new Database in phpMyAdmin with the same name of the database (otkrica.sql) file.
Select that database while Importing. Thank you.
New Database section in phpMyAdmin
Create a new Database in phpMyAdmin with the same name of the database (otkrica.sql) file.
Select that database while Importing. Thank you.
New Database section in phpMyAdmin
answered Apr 4 at 10:25
Sharan Salian
76
76
add a comment |
add a comment |
up vote
0
down vote
I fix this problem wait this way
enter image description here
attention: use as wampserver ver2.5 for build database in the server
after run wampserver, click left on the icon in notify bar and then click on phpmyadmin and create the database.
1
Do not post images as an answer to the question.
– Vineeth Sai
Nov 11 at 7:48
add a comment |
up vote
0
down vote
I fix this problem wait this way
enter image description here
attention: use as wampserver ver2.5 for build database in the server
after run wampserver, click left on the icon in notify bar and then click on phpmyadmin and create the database.
1
Do not post images as an answer to the question.
– Vineeth Sai
Nov 11 at 7:48
add a comment |
up vote
0
down vote
up vote
0
down vote
I fix this problem wait this way
enter image description here
attention: use as wampserver ver2.5 for build database in the server
after run wampserver, click left on the icon in notify bar and then click on phpmyadmin and create the database.
I fix this problem wait this way
enter image description here
attention: use as wampserver ver2.5 for build database in the server
after run wampserver, click left on the icon in notify bar and then click on phpmyadmin and create the database.
answered Nov 11 at 7:41
Reza
45
45
1
Do not post images as an answer to the question.
– Vineeth Sai
Nov 11 at 7:48
add a comment |
1
Do not post images as an answer to the question.
– Vineeth Sai
Nov 11 at 7:48
1
1
Do not post images as an answer to the question.
– Vineeth Sai
Nov 11 at 7:48
Do not post images as an answer to the question.
– Vineeth Sai
Nov 11 at 7:48
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f39278057%2ferror-sqlstatehy000-1049-unknown-database%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Have you actually created a database named
otkrica?– eggyal
Sep 1 '16 at 17:58
be sure you don't have more then one mysql installation. Try to set the port you are using like:
mysql:host=localhost;port=3307;dbname=testdb– cmnardi
Sep 1 '16 at 18:03
Yes, I did. It's in my project root folder and db.php is in root/core folder.
– Strahinjatronic
Sep 1 '16 at 18:05
this is not what i said. see in your database client the port of your mysql server instalation, and set it in your 'dsn' string
– cmnardi
Sep 1 '16 at 18:08
That did it. Thank you!
– Strahinjatronic
Sep 1 '16 at 19:06