Database connection not working while logging in to Symfony 3.4 app
up vote
0
down vote
favorite
I have deployed a Symfony website on Azure MySQL + PHP web app, and it deployed, but I was facing this error:
The reserved indicator "@" cannot start a plain scalar; you need to quote the scalar
So I wrapped up the db user and password in quotation but now when I am trying to login to my website I am facing this error:
php_network_getaddresses: getaddrinfo failed: No such host is known.
It seems the db connection is not working and whenever the code runs the query it breaks. I tried to run simple mysqli query as well and fetched the result successfully.
My Symfony version is 3.4.
PHP version is 7.2
MySQL version is 5.1
CODE:
Parameters.yml
parameters:
database_host: '`db_host`'
database_port: null
database_name: db_name
database_user: '`db_user`'
database_password: '`my_db_password`'
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
secret: b379ec1bf07cf3925582e96b26ffe5ad0052aff8
Config.yml
doctrine:
dbal:
server_version: 5.1
driver: pdo_mysql
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
charset: UTF8
types:
json: SonataDoctrineTypesJsonType
php symfony pdo azure-web-sites
add a comment |
up vote
0
down vote
favorite
I have deployed a Symfony website on Azure MySQL + PHP web app, and it deployed, but I was facing this error:
The reserved indicator "@" cannot start a plain scalar; you need to quote the scalar
So I wrapped up the db user and password in quotation but now when I am trying to login to my website I am facing this error:
php_network_getaddresses: getaddrinfo failed: No such host is known.
It seems the db connection is not working and whenever the code runs the query it breaks. I tried to run simple mysqli query as well and fetched the result successfully.
My Symfony version is 3.4.
PHP version is 7.2
MySQL version is 5.1
CODE:
Parameters.yml
parameters:
database_host: '`db_host`'
database_port: null
database_name: db_name
database_user: '`db_user`'
database_password: '`my_db_password`'
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
secret: b379ec1bf07cf3925582e96b26ffe5ad0052aff8
Config.yml
doctrine:
dbal:
server_version: 5.1
driver: pdo_mysql
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
charset: UTF8
types:
json: SonataDoctrineTypesJsonType
php symfony pdo azure-web-sites
Can you post your actual connection code please?
– War10ck
Nov 12 at 20:11
@War10ck added, please check the updated question
– Owais Aslam
Nov 13 at 5:55
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have deployed a Symfony website on Azure MySQL + PHP web app, and it deployed, but I was facing this error:
The reserved indicator "@" cannot start a plain scalar; you need to quote the scalar
So I wrapped up the db user and password in quotation but now when I am trying to login to my website I am facing this error:
php_network_getaddresses: getaddrinfo failed: No such host is known.
It seems the db connection is not working and whenever the code runs the query it breaks. I tried to run simple mysqli query as well and fetched the result successfully.
My Symfony version is 3.4.
PHP version is 7.2
MySQL version is 5.1
CODE:
Parameters.yml
parameters:
database_host: '`db_host`'
database_port: null
database_name: db_name
database_user: '`db_user`'
database_password: '`my_db_password`'
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
secret: b379ec1bf07cf3925582e96b26ffe5ad0052aff8
Config.yml
doctrine:
dbal:
server_version: 5.1
driver: pdo_mysql
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
charset: UTF8
types:
json: SonataDoctrineTypesJsonType
php symfony pdo azure-web-sites
I have deployed a Symfony website on Azure MySQL + PHP web app, and it deployed, but I was facing this error:
The reserved indicator "@" cannot start a plain scalar; you need to quote the scalar
So I wrapped up the db user and password in quotation but now when I am trying to login to my website I am facing this error:
php_network_getaddresses: getaddrinfo failed: No such host is known.
It seems the db connection is not working and whenever the code runs the query it breaks. I tried to run simple mysqli query as well and fetched the result successfully.
My Symfony version is 3.4.
PHP version is 7.2
MySQL version is 5.1
CODE:
Parameters.yml
parameters:
database_host: '`db_host`'
database_port: null
database_name: db_name
database_user: '`db_user`'
database_password: '`my_db_password`'
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
secret: b379ec1bf07cf3925582e96b26ffe5ad0052aff8
Config.yml
doctrine:
dbal:
server_version: 5.1
driver: pdo_mysql
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
charset: UTF8
types:
json: SonataDoctrineTypesJsonType
php symfony pdo azure-web-sites
php symfony pdo azure-web-sites
edited Nov 13 at 6:50
asked Nov 12 at 20:04
Owais Aslam
1,0801725
1,0801725
Can you post your actual connection code please?
– War10ck
Nov 12 at 20:11
@War10ck added, please check the updated question
– Owais Aslam
Nov 13 at 5:55
add a comment |
Can you post your actual connection code please?
– War10ck
Nov 12 at 20:11
@War10ck added, please check the updated question
– Owais Aslam
Nov 13 at 5:55
Can you post your actual connection code please?
– War10ck
Nov 12 at 20:11
Can you post your actual connection code please?
– War10ck
Nov 12 at 20:11
@War10ck added, please check the updated question
– Owais Aslam
Nov 13 at 5:55
@War10ck added, please check the updated question
– Owais Aslam
Nov 13 at 5:55
add a comment |
2 Answers
2
active
oldest
votes
up vote
2
down vote
According to your error information The reserved indicator "@" cannot start a plain scalar; you need to quote the scalar
, it was caused by the character @
which is a reserved indicator in YAML 1.2. Please refer to the YAML offical specification document to know it via search @
in browser. And more note details for using Symfony YAML (3.4) to parse YAML file, please see The YAML Format on the Symfony offical site, and here is a short reference below.
Strings containing any of the following characters must be quoted.
Although you can use double quotes, for these characters it is more
convenient to use single quotes, which avoids having to escape any
backslash :
:, {, }, [, ], ,, &, *, #, ?, |, -, <, >, =, !, %, @, `
The double-quoted style provides a way to express arbitrary strings, by
using to escape characters and sequences. For instance, it is very
useful when you need to embed a n or a Unicode character in a string.
Within your description, I can't see any @
in your code, therefore that I can not supply any code to help fixing the error. But I reproduce the error information via a simple code and hope it helps.
<?php
include_once('vendor/autoload.php');
use SymfonyComponentYamlYaml;
$value = Yaml::parse("hello: @world");
printf($value);
?>
The first character @
of hello
cause the same error. Maybe, the same issue happened when you refer the variable in Config.yml
. If you can update your code for more missing details, it's useful to help fixing.
Any concern, please feel free to let me know.
Thanks for your valuable answer :)
– Owais Aslam
Nov 15 at 17:34
add a comment |
up vote
0
down vote
accepted
Fixed it by adding URL based database configuration in my config.yml file as below.
doctrine:
dbal:
server_version: 5.1
driver: mysqli
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
# if the url option is specified, it will override the above config
url: pdo-mysql://db_user:db_password@127.0.0.1:3306/db_name
reference Link 1 Link 2
Hope it will help anybody else. :)
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
According to your error information The reserved indicator "@" cannot start a plain scalar; you need to quote the scalar
, it was caused by the character @
which is a reserved indicator in YAML 1.2. Please refer to the YAML offical specification document to know it via search @
in browser. And more note details for using Symfony YAML (3.4) to parse YAML file, please see The YAML Format on the Symfony offical site, and here is a short reference below.
Strings containing any of the following characters must be quoted.
Although you can use double quotes, for these characters it is more
convenient to use single quotes, which avoids having to escape any
backslash :
:, {, }, [, ], ,, &, *, #, ?, |, -, <, >, =, !, %, @, `
The double-quoted style provides a way to express arbitrary strings, by
using to escape characters and sequences. For instance, it is very
useful when you need to embed a n or a Unicode character in a string.
Within your description, I can't see any @
in your code, therefore that I can not supply any code to help fixing the error. But I reproduce the error information via a simple code and hope it helps.
<?php
include_once('vendor/autoload.php');
use SymfonyComponentYamlYaml;
$value = Yaml::parse("hello: @world");
printf($value);
?>
The first character @
of hello
cause the same error. Maybe, the same issue happened when you refer the variable in Config.yml
. If you can update your code for more missing details, it's useful to help fixing.
Any concern, please feel free to let me know.
Thanks for your valuable answer :)
– Owais Aslam
Nov 15 at 17:34
add a comment |
up vote
2
down vote
According to your error information The reserved indicator "@" cannot start a plain scalar; you need to quote the scalar
, it was caused by the character @
which is a reserved indicator in YAML 1.2. Please refer to the YAML offical specification document to know it via search @
in browser. And more note details for using Symfony YAML (3.4) to parse YAML file, please see The YAML Format on the Symfony offical site, and here is a short reference below.
Strings containing any of the following characters must be quoted.
Although you can use double quotes, for these characters it is more
convenient to use single quotes, which avoids having to escape any
backslash :
:, {, }, [, ], ,, &, *, #, ?, |, -, <, >, =, !, %, @, `
The double-quoted style provides a way to express arbitrary strings, by
using to escape characters and sequences. For instance, it is very
useful when you need to embed a n or a Unicode character in a string.
Within your description, I can't see any @
in your code, therefore that I can not supply any code to help fixing the error. But I reproduce the error information via a simple code and hope it helps.
<?php
include_once('vendor/autoload.php');
use SymfonyComponentYamlYaml;
$value = Yaml::parse("hello: @world");
printf($value);
?>
The first character @
of hello
cause the same error. Maybe, the same issue happened when you refer the variable in Config.yml
. If you can update your code for more missing details, it's useful to help fixing.
Any concern, please feel free to let me know.
Thanks for your valuable answer :)
– Owais Aslam
Nov 15 at 17:34
add a comment |
up vote
2
down vote
up vote
2
down vote
According to your error information The reserved indicator "@" cannot start a plain scalar; you need to quote the scalar
, it was caused by the character @
which is a reserved indicator in YAML 1.2. Please refer to the YAML offical specification document to know it via search @
in browser. And more note details for using Symfony YAML (3.4) to parse YAML file, please see The YAML Format on the Symfony offical site, and here is a short reference below.
Strings containing any of the following characters must be quoted.
Although you can use double quotes, for these characters it is more
convenient to use single quotes, which avoids having to escape any
backslash :
:, {, }, [, ], ,, &, *, #, ?, |, -, <, >, =, !, %, @, `
The double-quoted style provides a way to express arbitrary strings, by
using to escape characters and sequences. For instance, it is very
useful when you need to embed a n or a Unicode character in a string.
Within your description, I can't see any @
in your code, therefore that I can not supply any code to help fixing the error. But I reproduce the error information via a simple code and hope it helps.
<?php
include_once('vendor/autoload.php');
use SymfonyComponentYamlYaml;
$value = Yaml::parse("hello: @world");
printf($value);
?>
The first character @
of hello
cause the same error. Maybe, the same issue happened when you refer the variable in Config.yml
. If you can update your code for more missing details, it's useful to help fixing.
Any concern, please feel free to let me know.
According to your error information The reserved indicator "@" cannot start a plain scalar; you need to quote the scalar
, it was caused by the character @
which is a reserved indicator in YAML 1.2. Please refer to the YAML offical specification document to know it via search @
in browser. And more note details for using Symfony YAML (3.4) to parse YAML file, please see The YAML Format on the Symfony offical site, and here is a short reference below.
Strings containing any of the following characters must be quoted.
Although you can use double quotes, for these characters it is more
convenient to use single quotes, which avoids having to escape any
backslash :
:, {, }, [, ], ,, &, *, #, ?, |, -, <, >, =, !, %, @, `
The double-quoted style provides a way to express arbitrary strings, by
using to escape characters and sequences. For instance, it is very
useful when you need to embed a n or a Unicode character in a string.
Within your description, I can't see any @
in your code, therefore that I can not supply any code to help fixing the error. But I reproduce the error information via a simple code and hope it helps.
<?php
include_once('vendor/autoload.php');
use SymfonyComponentYamlYaml;
$value = Yaml::parse("hello: @world");
printf($value);
?>
The first character @
of hello
cause the same error. Maybe, the same issue happened when you refer the variable in Config.yml
. If you can update your code for more missing details, it's useful to help fixing.
Any concern, please feel free to let me know.
answered Nov 13 at 10:08
Peter Pan
10.2k2823
10.2k2823
Thanks for your valuable answer :)
– Owais Aslam
Nov 15 at 17:34
add a comment |
Thanks for your valuable answer :)
– Owais Aslam
Nov 15 at 17:34
Thanks for your valuable answer :)
– Owais Aslam
Nov 15 at 17:34
Thanks for your valuable answer :)
– Owais Aslam
Nov 15 at 17:34
add a comment |
up vote
0
down vote
accepted
Fixed it by adding URL based database configuration in my config.yml file as below.
doctrine:
dbal:
server_version: 5.1
driver: mysqli
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
# if the url option is specified, it will override the above config
url: pdo-mysql://db_user:db_password@127.0.0.1:3306/db_name
reference Link 1 Link 2
Hope it will help anybody else. :)
add a comment |
up vote
0
down vote
accepted
Fixed it by adding URL based database configuration in my config.yml file as below.
doctrine:
dbal:
server_version: 5.1
driver: mysqli
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
# if the url option is specified, it will override the above config
url: pdo-mysql://db_user:db_password@127.0.0.1:3306/db_name
reference Link 1 Link 2
Hope it will help anybody else. :)
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Fixed it by adding URL based database configuration in my config.yml file as below.
doctrine:
dbal:
server_version: 5.1
driver: mysqli
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
# if the url option is specified, it will override the above config
url: pdo-mysql://db_user:db_password@127.0.0.1:3306/db_name
reference Link 1 Link 2
Hope it will help anybody else. :)
Fixed it by adding URL based database configuration in my config.yml file as below.
doctrine:
dbal:
server_version: 5.1
driver: mysqli
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
# if the url option is specified, it will override the above config
url: pdo-mysql://db_user:db_password@127.0.0.1:3306/db_name
reference Link 1 Link 2
Hope it will help anybody else. :)
answered Nov 13 at 10:15
Owais Aslam
1,0801725
1,0801725
add a comment |
add a comment |
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%2f53269312%2fdatabase-connection-not-working-while-logging-in-to-symfony-3-4-app%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
Can you post your actual connection code please?
– War10ck
Nov 12 at 20:11
@War10ck added, please check the updated question
– Owais Aslam
Nov 13 at 5:55