title: A link to the server could not be established
body: <p>A very simple insert function, and yet. It gives some nasty errors...  </p>
  
  <p>Like:  </p>
  
  <pre><code>Warning: mysql_query(): Access denied for user '***.'@'***.one.com' (using password: NO) in /customers/***.be/***.be/httpd.www/belastingen/classes/btw.php on line 24 Warning: mysql_query(): A link to the server could not be established in /customers/***.be/***.be/httpd.www/belastingen/classes/btw.php on line 24
  </code></pre>
  
  <p>And this is the code:  </p>
  
  <pre><code>&lt;?php
  
      if(isset($_POST['submit'])){
  
      $naam = $_POST['name'];
      $email = $_POST['email'];
      $kind1 = $_POST['kind1'];
      $kind2 = $_POST['kind2'];
      $kind3 = $_POST['kind3'];
      $kind4 = $_POST['kind4'];
      $kind5 = $_POST['kind5'];
      $captcha = $_POST['captcha'];
  
          if ($captcha == 2){
              if (!empty($_POST['name']) &amp;&amp; !empty($_POST['email']) &amp;&amp; !empty($_POST['kind1'])) {
                      $insert = "INSERT INTO belastingen (ouder, email, kind1, kind2, kind3, kind4, kind5) VALUES (
                              '".$naam."',
                              '".$email."',
                              '".$kind1."',
                              '".$kind2."',
                              '".$kind3."',
                              '".$kind4."',
                              '".$kind5."')";
                  if (!mysql_query($insert)) {
                      echo "&lt;div class=\"feedback\"&gt;query invoeren faalt&lt;/div&gt;";
                  } else { 
                      echo "&lt;div class=\"feedback\"&gt;Uw registratie werd goed geregistreerd&lt;/div&gt;";
                  }
  
  
                  }    else {
                  echo "&lt;div class=\"feedback\"&gt;falen, niveau 2&lt;/div&gt;";
              }
          } else {
              echo "&lt;div class=\"feedback\"&gt;captcha probleem&lt;/div&gt;";
          }
      }   
  ?&gt;
  </code></pre>
  
  <p>And don't worry about the MySQL-injection. Adding as we speak.
  Any thought about the error?
  And yes I'm sure the data for connection to the database are correct.</p>
  
  <p><strong>UPDATE 1</strong>
  This is my <code>inc.php</code>-file, included on top of the index.php file.</p>
  
  <pre><code>&lt;?php
    define('MYSQL_HOST',  '***.be.mysql');
    define('MYSQL_DB',    '***');
    define('MYSQL_USER',  '***');
    define('MYSQL_PASSW', '***');
  
    require_once 'classes/dbconnections.php';
    require_once 'classes/btw.php';
    $_DB = new DBConnection(MYSQL_HOST, MYSQL_DB, MYSQL_USER, MYSQL_PASSW);
  ?&gt;
  </code></pre>
  
  <p><strong>UPDATE 2</strong>
  This is my <code>dbconnections.php</code>-file</p>
  
  <pre><code>&lt;?php
  
  class DBConnection {
  
    public  $host;
    public  $db;
    public  $user;
    public  $password;
  
    private $_connection;
  
    public function __construct($host = null, $db = null, $user = null, $password = null) {
      $this-&gt;host     = $host;
      $this-&gt;db       = $db;
      $this-&gt;user     = $user;
      $this-&gt;password = $password;
      $this-&gt;connect();
    }
  
    private function connect(){
      $this-&gt;_connection = mysql_connect($this-&gt;host, $this-&gt;user, $this-&gt;password);
      if(!$this-&gt;_connection) {
        die("An error occured---- while connecting to the database: ".mysql_errno()." - ".mysql_error());
      } else{
        $selected = mysql_select_db($this-&gt;db, $this-&gt;_connection);
        if(!$selected) {
          die("An error occured while connecting to the database: ".mysql_errno()." - ".mysql_error());
        }
      } 
    }
  
    public function listing($sql) {
      $result = mysql_query($sql, $this-&gt;_connection);
      while($row=mysql_fetch_array($result)) {
        $return[] = $row;
      }
      return $return;
    }
  
    public function select($sql) {
      $result = mysql_query($sql, $this-&gt;_connection);
      return mysql_fetch_array($result);
    }
  
    public function insert($sql) {
      mysql_query($sql, $this-&gt;_connection);
      return mysql_affected_rows($this-&gt;_connection);
    }
  
    public function delete($sql) {
      mysql_query($sql, $this-&gt;_connection);
      return mysql_affected_rows($this-&gt;_connection);
    }
  
    public function escape($value) {
      return mysql_real_escape_string($value);
    }
  
  }
  
  ?&gt;
  </code></pre>
  
  <p><strong>UPDATE 3</strong><br>
  The error I get when replacing the thins suggested below</p>
  
  <pre><code>Notice: Undefined variable: _DB in /customers/***/***/httpd.www/belastingen/classes/btw.php on line 13 Fatal error: Call to a member function insert() on a non-object in /customers/***/***/httpd.www/belastingen/classes/btw.php on line 13
  </code></pre>