title: Check whether a mysql_connect() failed or not?
body: <p>Hey i'm trying to find out whether my sql query failed or not. I want it so if it does fail redirect to form page using the code below:</p>
  
  <pre><code>$checkconnection = mysql_connect('localhost', $dbuser, $dbpass)
                                                  or die();
  
  
  if(!$checkconnection)
  {
  $_SESSION['errormsg'] = "&lt;div style='padding-left: 50px;color:#FF0000'&gt;Cannot connect to specfied database!&lt;/div&gt;";
  header("Location: install.php");
  }else{
  echo('Connection Successful!');
  }
  </code></pre>
  
  <p>using that all it says is this:</p>
  
  <pre><code>Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'nzcraftn_admin'@'localhost' (using password: YES) in /home/nzcraftn/public_html/phishnet/install/install_submit.php on line 17
  </code></pre>