Inserting Data Into Database

I have spent all day on it and I have a book on this, and I still can’t seem to figure it out. I have searched the internet and in my book, but everything seems to be right. I keep keeping this error message when I try to enter form information from PHP into my MySQL database:

There was a database error when executing insert into clienttable values
                ('dfgdfgfg', 'dfg', '', 'dfg', 'dfg', 'dfg', 'gdfg', 'gdf', 'df', 'dfgdfg')  

Here’s the current code:

<?php
  // story_submit.php
  // add / modify story record

  include_once('header.php');
?>
<br><div align="center"><table border="0" width="500">
    <tr>
        <td>
        <h1><font face="Arial" color="#0066CC">New Lead</h1></font>
        </td>
    </tr>
</table><table border="0" width="520"><tr>
<td><font face="Arial">
<?php
  
    if (!$salesperson || !$client || !$project || !$address || !$contactname1 || !$contactphone1 || !$contactemail1 || !$contactname2 || !$contactphone2 || !$contactemail2 )
  {
     echo '<font color="red">You have not entered all the required details.<br />'
          .'Please go back and try again.</font>';
  }
  if (!get_magic_quotes_gpc())
  {
    $salesperson= addslashes($salesperson);
    $client = addslashes($client);
    $project = addslashes($project);
    $address = addslashes($address);
    $contactname1= addslashes($contactname1);
    $contactphone1 = addslashes($contactphone1);
    $contactemail1 = addslashes($contactemail1);
    $contactname2= addslashes($contactname2);
    $contactphone2 = addslashes($contactphone2);
    $contactemail2 = addslashes($contactemail2);
  }


if ( $salesperson )
{
    echo '<p><b>Thank You </b>';
    echo $salesperson.'</b><b><p><h3></font><font face="Arial" color="#0066CC">Here is the information entered on this new lead:</h3></font><font face="Arial" color="#000000"></b></p>';
}
else
{
    echo '<p><b>Who Are You?: </b>';
    echo '<font color="red">You did not enter <b>Your Name</b>.</font><br />';
}

if ( $client )
{
    echo '<p><b>Lead Name: </b>';
    echo $client.'<br />';
}
else
{
    echo '<p><b>Lead Name: </b>';
    echo '<font color="red">You did not enter a <b>Client Name</b>.</font><br />';
}

if ( $project )
{
    echo '<p><b>Project Name: </b>';
    echo $project.'<br />';
}
else
{
    echo '<p><b>Project Name: </b>';
    echo '<font color="red">You did not enter a <b>Project Name</b>.</font>';
}

if($projecttype == 'a')
  echo '<p><b>Lead Type: </b>Live Sound Reinforcement.</p>';
elseif($projecttype== 'b')
  echo '<p><b>Lead Type: </b>Sound Design & Integration.</p>';


if ( $address )
{
    echo '<p><b>Address: </b>';
    echo $address.'<br />';
}
else
{
    echo '<p><b>Address: </b>';
    echo '<font color="red">You did not enter an <b>Address</b>.</font>';
}

if ( $contactname1 )
{
    echo '<p><b>Contact 1: </b>';
    echo $contactname1.'<br />';
}
else
{
    echo '<p><b>Contact 1: </b>';
    echo '<font color="red">You did not enter a <b>Contact 1 Name</b>.</font>';
}

if ( $contactphone1 )
{
    echo '<b><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Phone: </b>';
    echo $contactphone1.'<br />';
}
else
{
    echo '<b><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Phone: </b>';
    echo '<font color="red">You did not enter a <b>Contact 1 Phone</b>.</font>';
}

if ( $contactemail1 )
{
    echo '<b><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Email: </b>';
    echo $contactemail1.'<br />';
}
else
{
    echo '<b><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Email: </b>';
    echo '<font color="red">You did not enter a <b>Contact 1 Email</b>. (Put "N/A" if none)</font>';
}

if ( $contactname2 )
{
    echo '<p><b>Contact 1: </b>';
    echo $contactname2.'<br />';
}
else
{
    echo '<p><b>Contact 1: </b>';
    echo '<font color="red">You did not enter a <b>Contact 1 Name</b>.</font>';
}

if ( $contactphone2 )
{
    echo '<b><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Phone: </b>';
    echo $contactphone2.'<br />';
}
else
{
    echo '<b><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Phone: </b>';
    echo '<font color="red">You did not enter a <b>Contact 1 Phone</b>.</font>';
}

if ( $contactemail2 )
{
    echo '<b><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Email: </b>';
    echo $contactemail2.'<br />';
}
else
{
    echo '<b><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Email: </b>';
    echo '<font color="red">You did not enter a <b>Contact 1 Email</b>. (Put "N/A" if none)</font>';
}

if ( $status )
    echo '<b><br>Status: </b>';
    echo $status.'<p>';



function db_connect()
{
$hostname = "localhost";
$db_user = "hjghj";
$db_password = "ghjghj";
$db_table = "clienttable";
$database = "ghjghj";

$handle = mysql_connect($hostname, $db_user, $db_password)or die("cannot connect"); 
mysql_select_db($database)or die("cannot select DB"); 
   if (!$handle)
   {
     return false;
   }
   return $handle;
   exit;
}
  
  $salesperson = $_POST['salesperson'];
  $client = $_POST['client'];
  $project = $_POST['project'];
  $address = $_POST['address'];
  $contactname1 = $_POST['contactname1'];
  $contactphone1 = $_POST['contactphone1'];
  $contactemail1 = $_POST['contactemail1'];
  $contactname2 = $_POST['contactname2'];
  $contactphone2 = $_POST['contactphone2'];
  $contactemail2 = $_POST['contactemail2'];
  $status = $_POST['status'];
  
  
    $query = "insert into clienttable
                 (salesperson, client, project, address, contactname1, contactphone1, contactemail1, contactname2, contactphone2, contactemail2, status)
              values
                ('$salesperson', '$client', '$project', '$address', '$contactname1', '$contactphone1', '$contactemail1', '$contactname2', '$contactphone2', '$contactemail2', '$status')"; 
$result = mysql_query($handle, $query);

  if (!$result) 
  {
    echo "There was a database error when executing <pre>$query</pre>";
    echo mysql_error();
    exit;
  }


?>
<?php

?>