title: error: Access denied for user 'root'@'localhost' (using password: NO)
body: <p>I'm trying to implement a login function that allows me to extract data from facebook and save them on my moodle Website. Unfortunately, I'm not a programmer and I'm having some problems. In particular, I'm having some difficulties -I believe- related to the permission rights when I try to "write" the data extracted from fb on a MySQL database.</p>
  
  <p>This is what I have done so far:</p>
  
  <p>I managed to extract from Fb the data that interest me and I tried to save them to a MySQL database (created through cpannel). The code I used to access the database is basically this (with the correct parameters for my database):</p>
  
  <pre><code>// Create connection
  
  $ Db = new mysqli ($ localhost, $ username, $ password, $ database);
  
  // Check connection
  
  if ($ db&gt; connect_error) {
  
      die ( "Connection failed:". $ db-&gt; connect_error);
  
  }
  </code></pre>
  
  <p>But when I connect to the web page I get this error: "Connection failed: Access denied for user 'root' @ 'localhost' (using password: NO)"</p>
  
  <p>The problem seems to be that the user/pass are incorrect. In fact, I am sure the data correspond to those included in CPannel by me at the time of database creation. The associated user has all active privileges.</p>
  
  <p>I did some research and it it seemed that the problem could be associated with some "automatic" setting of Moodle. So I uninstalled moodle but nothing has changed.</p>
  
  <p>I also tried to change the code:</p>
  
  <pre><code>$config = parse_ini_file('/config.ini');
  
  // Connect to database
  
  $mysqli = new mysqli($config['servername'], $config['username'], $config['password'], $config['dbname']);
  
  printf("\n ".date("Y-m-d h:i:sa") . " - Establishing connection to " . $config['dbname'] . " on " . $config['servername'] . ".\n");
  
  // Check connection
  
  if ($mysqli-&gt;connect_error) {
  
      die('Error : (' . $mysqli-&gt;connect_errno . ') ' . $mysqli-&gt;connect_error);
  
      printf("\n ".date("Y-m-d h:i:sa") . " - Connection failed. Returned error: " . mysqli_connect_error() . "\n");
  
  } else {
  
       printf("\n ".date("Y-m-d h:i:sa") . " - Connection successful.\n");
  
  }
  </code></pre>
  
  <p>Unfortunately I had no luck ...</p>
  
  <p>This is the tutorial i followed to implement the function:</p>
  
  <p><a href="https://www.youtube.com/watch?v=N5Kka43giyY&amp;index=30&amp;list=PLmpuiTmSb3xCLwwkpXeuJxwKyljf7e3Tx" rel="nofollow noreferrer">https://www.youtube.com/watch?v=N5Kka43giyY&amp;index=30&amp;list=PLmpuiTmSb3xCLwwkpXeuJxwKyljf7e3Tx</a></p>
  
  <p>I am very inexperienced, but it seems to me that the problem arises when I define password in cpannel ... it is as if the password had no value ..
  Any ideas on how I can resolve it?</p>