title: PHP MySQL authentication error
body: <p>I have created an html form (demo.html) &amp; POST it's value to a php file (demo1.php). Then i created database in MySQL &amp; wrote connection code in the php file (demo1.php) but it gives the following error </p>
  
  <blockquote>
    <p>Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in C:\xampp\htdocs\demo1.php on line 8
    Error connecting to mysql</p>
  </blockquote>
  
  <pre><code>&lt;?php
  // contact to database
  $dbhost = 'localhost';
  $dbuser = 'root';
  $dbpass = 'password';
  
  $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
  //$conn = mysql_connect("localhost","root","password") or die ('Error connecting to mysql');
  
  $dbname = 'test';
  mysql_select_db($dbname,$conn);
  
  //$connect = mysql_connect("localhost", "root", "pass") or die ("Error , check your server connection.");
  
  //mysql_select_db("test");
  
  
  
  //Get data in local variable
  
  $v_name=$_POST['name'];
  
  $v_email=$_POST['email'];
  
  $v_msg=$_POST['msg'];
  
  
  
  // check for null values
  
  if ($v_name==""  or $v_msg=="")
  
  echo "All fields must be entered, hit back button and re-enter information";
  
  else{
  
  $query="insert into contact(name,email,msg) values('$v_name','$v_email','$v_msg')";
  
  mysql_query($query)  or die(mysql_error());
  
  echo "Your message has been received";
  
  mysql_close($conn);
  
  }
  
  ?&gt;
  </code></pre>