Iive got the process sorted now I think, but I get an annoying error and I cant work out where its is because of the error, and ive been through every line and cant see the issue.
if(isset($_POST['btnduplicate']))
{
$sr=$_POST['srno1'];
$flag=$_POST['flag'];
if ($flag==0)
{
$query = "select 'ID', 'Contract_Number', 'Contract_Status', 'Company_Name', 'Invoice_Street', 'Invoice_City', 'Invoice_State', 'Invoice_Country', 'Invoice_Postcode', 'Invoice_Tax_Code', 'Invoice_Telephone', 'Invoice_Fax', 'Invoice_Contact_Name', 'Invoice_Email', 'Annual_Contract_Value', 'Invoicing_Profile', 'Invoice_Paid_By', 'Currency_of_Contract', 'Contract_Start', 'Contract_End', 'Renewal_Date', 'Contract_Length', 'Quote_Number', 'Site_Name', 'Street', 'City', 'State', 'Country', 'Postcode', 'Type_of_Establishment', 'No_of_Rooms', 'Group_Name', 'Invoice_Value', 'Invoice_Currency', 'Payment_Contact', 'Payment_Contact_Tel', 'Invoice_Frequency', 'Seasonal_or_Full', 'Month_Opens', 'Month_Closes', 'Brandcheck_Frequency', 'Standardscheck_Frequency', 'Roomcheck_Frequency', 'Foodcheck_Frequency', 'Crisischeck_Frequency', 'Poolcheck_Frequency', 'Firecheck_Frequency', 'Aquacheck_Frequency', 'Spacheck_Frequency', 'Safetycheck_Frequency', 'Accesscheck_Frequency', 'Ecocheck_Frequency', 'Supplycheck_Frequency', 'Dinecheck_Frequency', 'Tourcheck_Frequency', 'Training_Days', 'Labcheck_Aqua_Frequency', 'Labcheck_Food_Frequency', 'Labcheck_Pool_Frequency', 'Labcheck_Room_Frequency', 'Legionella_Test_Frequency', 'Additional_Sampling', 'No_of_Modules', 'Principle_Contact', 'Principle_Telephone', 'Preferred_Language', 'Principle_Contact_Job_Title', 'Principle_Contact_Email' from Intranet where 'ID' = $sr";
$res = sqlsrv_query($conn, $query);
while ($result = sqlsrv_fetch_array($res, SQLSRV_FETCH_ASSOC)) {
$new1 = $result["Contract_Number"];
$new2 = $result["Contract_Status"];
$new3 = $result["Company_Name"];
$new4 = $result["Invoice_Street"];
$new5 = $result["Invoice_City"];
$new6 = $result["Invoice_State"];
$new7 = $result["Invoice_Country"];
$new8 = $result["Invoice_Postcode"];
$new9 = $result["Invoice_Tax_Code"];
$new10 = $result["Invoice_Telephone"];
$new11 = $result["Invoice_Fax"];
$new12 = $result["Invoice_Contact_Name"];
$new13 = $result["Invoice_Email"];
$new14 = $result["Annual_Contract_Value"];
$new15 = $result["Invoicing_Profile"];
$new16 = $result["Invoice_Paid_By"];
$new17 = $result["Currency_of_Contract"];
$new18 = $result["Contract_Start"];
$new19 = $result["Contract_End"];
$new20 = $result["Renewal_Date"];
$new21 = $result["Contract_Length"];
$new22 = $result["Quote_Number"];
$new23 = $result["Site_Name"];
$new24 = $result["Street"];
$new25 = $result["City"];
$new26 = $result["State"];
$new27 = $result["Country"];
$new28 = $result["Postcode"];
$new29 = $result["Type_of_Establishment"];
$new30 = $result["No_of_Rooms"];
$new31 = $result["Group_Name"];
$new32 = $result["Invoice_Value"];
$new33 = $result["Invoice_Currency"];
$new34 = $result["Payment_Contact"];
$new35 = $result["Payment_Contact_Tel"];
$new36 = $result["Invoice_Frequency"];
$new37 = $result["Seasonal_or_Full"];
$new38 = $result["Month_Opens"];
$new39 = $result["Month_Closes"];
$new40 = $result["Brandcheck_Frequency"];
$new41 = $result["Standardscheck_Frequency"];
$new42 = $result["Roomcheck_Frequency"];
$new43 = $result["Foodcheck_Frequency"];
$new44 = $result["Crisischeck_Frequency"];
$new45 = $result["Poolcheck_Frequency"];
$new46 = $result["Firecheck_Frequency"];
$new47 = $result["Aquacheck_Frequency"];
$new48 = $result["Spacheck_Frequency"];
$new49 = $result["Safetycheck_Frequency"];
$new50 = $result["Accesscheck_Frequency"];
$new51 = $result["Ecocheck_Frequency"];
$new52 = $result["Supplycheck_Frequency"];
$new53 = $result["Dinecheck_Frequency"];
$new54 = $result["Tourcheck_Frequency"];
$new55 = $result["Training_Days"];
$new56 = $result["Labcheck_Aqua_Frequency"];
$new57 = $result["Labcheck_Food_Frequency"];
$new58 = $result["Labcheck_Pool_Frequency"];
$new59 = $result["Labcheck_Room_Frequency"];
$new60 = $result["Legionella_Test_Frequency"];
$new61 = $result["Additional_Sampling"];
$new62 = $result["No_of_Modules"];
$new63 = $result["Principle_Contact"];
$new64 = $result["Principle_Telephone"];
$new65 = $result["Preferred_Language"];
$new66 = $result["Principle_Contact_Job_Title"];
$new67 = $result["Principle_Contact_Email"];
}
$query2 = "insert into Intranet (Contract_Number,Contract_Status,Company_Name,Invoice_Street,Invoice_City,Invoice_State,Invoice_Country,Invoice_Postcode,Invoice_Tax_Code,Invoice_Telephone,Invoice_Fax,Invoice_Contact_Name,Invoice_Email,Annual_Contract_Value,Invoicing_Profile,Invoice_Paid_By,Currency_of_Contract,Contract_Start,Contract_End,Renewal_Date,Contract_Length,Quote_Number,Site_Name,Street,City,State,Country,Postcode,Type_of_Establishment,No_of_Rooms,Group_Name,Invoice_Value,Invoice_Currency,Payment_Contact,Payment_Contact_Tel,Invoice_Frequency,Seasonal_or_Full,Month_Opens,Month_Closes,Brandcheck_Frequency,Standardscheck_Frequency,Roomcheck_Frequency,Foodcheck_Frequency,Crisischeck_Frequency,Poolcheck_Frequency,Firecheck_Frequency,Aquacheck_Frequency,Spacheck_Frequency,Safetycheck_Frequency,Accesscheck_Frequency,Ecocheck_Frequency,Supplycheck_Frequency,Dinecheck_Frequency,Tourcheck_Frequency,Training_Days,Labcheck_Aqua_Frequency,Labcheck_Food_Frequency,Labcheck_Pool_Frequency,Labcheck_Room_Frequency,Legionella_Test_Frequency,Additional_Sampling,No_of_Modules,Principle_Contact,Principle_Telephone,Preferred_Language,Principle_Contact_Job_Title,Principle_Contact_Email)".
"VALUES($new1,$new2,$new3,$new4,$new5,$new6,$new7,$new8,$new9,$new10,$new11,$new12,$new13,$new14,$new15,$new16,$new17,$new18,$new19,$new20,$new21,$new22,$new23,$new24,$new25,$new26,$new27,$new28,$new29,$new30,$new31,$new32,$new33,$new34,$new35,$new36,$new37,$new38,$new39,$new40,$new41,$new42,$new43,$new44,$new45,$new46,$new47,$new48,$new49,$new50,$new51,$new52,$new53,$new54,$new55,$new56,$new57,$new58,$new59,$new60,$new61,$new62,$new63,$new64,$new65,$new66,$new67)";
$res2 = sqlsrv_query($conn, $query2);
if( $res2 === false )
{
echo "Error in executing query.</br>";
die( print_r( sqlsrv_errors(), true));
}
sqlsrv_free_stmt( $res2);
$flag=1;
}
}
This is the error
Error in executing query.
Array ( [0] => Array ( [0] => 42000 [SQLSTATE] => 42000 [1] => 102 [code] => 102 [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near ‘,’. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near ‘,’. ) )