php Drupal 7.54设置aws elasticbeanstalk

I am trying to insert AWS environment variables into the database section of the settings.php in drupal 7.54. Ive followed the elastic beanstalk guide for variable name and replicated them in docker with environment variables.

$dbhost = $_SERVER['RDS_HOSTNAME'];
$dbname = $_SERVER['RDS_DB_NAME'];
$dbuser = $_SERVER['RDS_USERNAME'];
$dbpasswd = $_SERVER['RDS_PASSWORD'];
$dbport = $_SERVER['RDS_PORT'];
$memcache1 = $_SERVER['MEMCACHED_ENDPOINT_1'];
$memcache2 = $_SERVER['MEMCACHED_ENDPOINT_2'];
$memcache3 = $_SERVER['MEMCACHED_ENDPOINT_3'];
$memcache4 = $_SERVER['MEMCACHED_ENDPOINT_4'];

Im then wanting to pass those variable values into the array.

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => " $dbname ",
      'username' => " $dbuser ",
      'password' => " $dbpasswd ",
      'host' => " $dbhost ",
      'port' => " $dbport ",
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);

However it doesnt seem to be picking up the values, it does work if the value are statically entered.

Many thanks help for any help on this.

Dump all variable to check if you have data in it !

I attract your attention, your code is opened to sql injection I think it's a very bad way..

More you can write it like this , double quote are useless :

 $databases = array (
      'default' =>
      array (
        'default' =>
        array (
          'database' =>  $dbname ,
          'username' =>  $dbuser ,
          'password' =>  $dbpasswd ,
          'host' =>  $dbhost ,
          'port' =>  $dbport ,
          'driver' => 'mysql',
          'prefix' => '',
        ),
      ),
    );