title: Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'a8221325'@'localhost' (using password: NO)
body: <p>Hi for some reason I am not aware of I keep receiving the following errors:</p>
  
  <pre><code>Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'a8221325'@'localhost' (using password: NO) in /home/a8221325/public_html/add.php on line 11
  
  Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/a8221325/public_html/add.php on line 11
  
  Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'a8221325'@'localhost' (using password: NO) in /home/a8221325/public_html/add.php on line 12
  
  Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/a8221325/public_html/add.php on line 12
  </code></pre>
  
  <p>From the research I've done I feel like the problem is in the way I connect to my database, but I'm not entirely sure. If someone could help me get my code to work it'd be awesome!
  So far my site consists of two pages, test and add here is their code:</p>
  
  <p>test.html:</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;form action="add.php" method="post" name="form1" id="form1"&gt;
    &lt;label for="name"&gt;Text Field:&lt;/label&gt;
    &lt;input type="text" name="name" id="name"&gt;
    &lt;label for="password"&gt;Text Field:&lt;/label&gt;
    &lt;input type="text" name="password" id="password"&gt;
    &lt;input type="submit" name="submit" id="submit" value="Submit"&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>add.php:</p>
  
  <pre><code>&lt;?php
  $con=mysqli_connect("mysql1.000webhost.com","a8221325_admin","**************","a8221325_prom");
  
  // Check connection
  if (mysqli_connect_errno())
    {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
  
  $escapedName = mysql_real_escape_string($_POST['name']); # use whatever escaping function your db requires this is very important.
  $escapedPW = mysql_real_escape_string($_POST['password']);
  
  # generate a random salt to use for this account
  $salt = bin2hex(mcrypt_create_iv(32, MCRYPT_DEV_URANDOM));
  
  $saltedPW =  $escapedPW . $salt;
  
  $hashedPW = hash('sha256', $saltedPW);
  
  $query = "insert into user (name, password, salt) values ('$escapedName', '$hashedPW', '$salt'); ";
  ?&gt;
  </code></pre>
  
  <p>Thank you!</p>