Database connection not working while logging in to Symfony 3.4 app












0














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









share|improve this question
























  • 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


















0














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









share|improve this question
























  • 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
















0












0








0







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









share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 at 6:50

























asked Nov 12 at 20:04









Owais Aslam

1,0851726




1,0851726












  • 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










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














2 Answers
2






active

oldest

votes


















2














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.






share|improve this answer





















  • Thanks for your valuable answer :)
    – Owais Aslam
    Nov 15 at 17:34



















0














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. :)






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    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

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    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.






    share|improve this answer





















    • Thanks for your valuable answer :)
      – Owais Aslam
      Nov 15 at 17:34
















    2














    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.






    share|improve this answer





















    • Thanks for your valuable answer :)
      – Owais Aslam
      Nov 15 at 17:34














    2












    2








    2






    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.






    share|improve this answer












    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.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 13 at 10:08









    Peter Pan

    10.7k3823




    10.7k3823












    • 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




    Thanks for your valuable answer :)
    – Owais Aslam
    Nov 15 at 17:34













    0














    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. :)






    share|improve this answer


























      0














      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. :)






      share|improve this answer
























        0












        0








        0






        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. :)






        share|improve this answer












        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. :)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 13 at 10:15









        Owais Aslam

        1,0851726




        1,0851726






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Bressuire

            Vorschmack

            Quarantine