Hello:
I'm trying to insert my form two table in mysql. I have the following but only insert to one table (ajax table query) is successfull. Any ideas what I'm doing wrong.
<?php
//error_reporting(0);
//error_reporting(E_ERROR | E_WARNING | E_PARSE);
error_reporting(E_ALL);
$host = "localhost";
$login_name = "dsdsdt";
$password = ".........";
$link=mysql_connect("$host","$login_name","$password");
mysql_select_db("shop", $link);
//or die("Could not find database");
//echo mysql_errno() . ": " . mysql_error(). "\n";
// define each variable
if(isset($_POST['submit']))//this defines any variable that are not define below
{
//ajax table
$firstname= mysql_real_escape_string($_POST['firstname']);
$lastname= mysql_real_escape_string($_POST['lastname']);
$address= mysql_real_escape_string($_POST['address']);
$city= mysql_real_escape_string($_POST['city']);
$state= mysql_real_escape_string($_POST['state']);
$zipcode= mysql_real_escape_string($_POST['zipcode']);
$add_type= mysql_real_escape_string($_POST['add_type']);
$areacode=mysql_real_escape_string($_POST['areacode']);
$phoneprefix=mysql_real_escape_string($_POST['phoneprefix']);
$phonesufix=mysql_real_escape_string($_POST['phonesufix']);
$tel_type=mysql_real_escape_string($_POST['tel_type']);
$cellareacode=$_POST['cellareacode'];
$cellprefix=mysql_real_escape_string($_POST['cellprefix']);
$cellsufix=mysql_real_escape_string($_POST['cellsufix']);
$email=mysql_real_escape_string($_POST['email']);
$commentonclient=mysql_real_escape_string($_POST['commentonclient']);
$theDate=mysql_real_escape_string($_POST['theDate']);
$servicedesc=($_POST['servicedesc']);
$servicedesc= "<br/>".'On '.date('m/d/y'.' @ '.'h:i')."<br/>".'We performed the following:<br/>'.""."\n$servicedesc<br/><br/>----End of Service Report----"."<br/>";//this lines seem to have corrected the displaying of text in service history
//$inputbox= "\n".'On '.date('m/d/y'.' @ '.'h:i')."\n".'We performed the following:'."\n"."\n$inputbox\n\n----End of Service Report----"."\n";
//second table
$lastname= mysql_real_escape_string($_POST['lastname']);
$dhtmlgoodies_subcategory= mysql_real_escape_string($_POST['dhtmlgoodies_subcategory']);
$clientID=mysql_real_escape_string($_POST['clientID']);
$registeredstate=mysql_real_escape_string($_POST['registeredstate']);
$commentonclient=mysql_real_escape_string($_POST['commentonclient']);
$theDate=mysql_real_escape_string($_POST['theDate']);
$dhtmlgoodies_category=mysql_real_escape_string($_POST['dhtmlgoodies_category']);
$caryear=mysql_real_escape_string($_POST['caryear']);
$servicearea=mysql_real_escape_string($_POST['servicearea']);
$currentmileage=mysql_real_escape_string($_POST['currentmileage']);
$servicedesc=($_POST['servicedesc']);
$servicedesc= "<br/>".'On '.date('m/d/y'.' @ '.'h:i')."<br/>".'We performed the following:<br/>'.""."\n$servicedesc<br/><br/>----End of Service Report----"."<br/>";//this lines seem to have corrected the displaying of text in service history
//$inputbox= "\n".'On '.date('m/d/y'.' @ '.'h:i')."\n".'We performed the following:'."\n"."\n$inputbox\n\n----End of Service Report----"."\n";
//ajax table query
$mysql_query=("INSERT ajax_client SET firstname='$firstname', lastname='$lastname', address='$address', city='$city', state='$state', zipcode='$zipcode', add_type='$add_type', areacode='$areacode', phoneprefix='$phoneprefix', phonesufix='$phonesufix', tel_type='$tel_type',
cellareacode='$cellareacode', cellprefix='$cellprefix', cellsufix='$cellsufix', cell_type='$cell_type', email='$email', commentonclient='$commentonclient', servicearea='$servicearea', servicedesc ='$servicedesc'");
$result=mysql_query($mysql_query);
if(!$result){die("Error: ".mysql_error());
$id = mysql_insert_id();
//vehicle table
$mysql_query=("INSERT additional_cars SET id='$id', lastname='$lastname', clientID='$clientID', registeredstate='$registeredstate', dhtmlgoodies_category='$dhtmlgoodies_category', dhtmlgoodies_subcategory='$dhtmlgoodies_subcategory',caryear='$caryear', servicearea='$servicearea',
currentmileage='$currentmileage', servicedesc ='$servicedesc'");
echo("<p>Error adding data" .
mysql_error() . "</p>");
mysql_close($link);
}
?>
No errors are produced
Best,
Mossa