<?php
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
/*
// Create database

if (mysql_query("CREATE DATABASE admin",$con))
  {
  echo "Database created";
  }
else
  {
  echo "Error creating database: " . mysql_error();
  }
*/

/*
 CREATE TABLE `admin`.`payment_invoice` (
`CompanyName` VARCHAR( 100 ) NOT NULL ,
`InvoiceNo.` INT( 5 ) NOT NULL ,
`Address` VARCHAR( 100 ) NOT NULL ,
`InvoiceDate` DATE NOT NULL ,
`Item` VARCHAR( 100 ) NOT NULL ,
`Description` VARCHAR( 20 ) NOT NULL ,
`Rate` INT( 20 ) NOT NULL ,
`Qty` VARCHAR( 100 ) NOT NULL ,
`Unit` INT( 20 ) NOT NULL ,
`Price` INT( 20 ) NOT NULL ,
`Amount` INT( 20 ) NOT NULL ,
`ServiceTaxRegNo` INT( 20 ) NOT NULL ,
`AmountTotal` INT( 20 ) NOT NULL ,
`PanNo.` INT( 20 ) NOT NULL ,
`ServiceTax` INT( 20 ) NOT NULL ,
`CategoryOfServices` VARCHAR( 100 ) NOT NULL ,
`EducationCess` INT( 20 ) NOT NULL ,
`SecondaryEducationCess` INT( 20 ) NOT NULL,
`ShareOfClame` INT( 20 ) NOT NULL ,
`TotalValue` VARCHAR( 100 ) NOT NULL ,
`InInteger` INT( 10 ) NOT NULL ,
`CheckedBy` VARCHAR( 100 ) NOT NULL ,
`VerifiedBy` VARCHAR( 100 ) NOT NULL ,
`ForBusinessPartner` VARCHAR( 100 ) NOT NULL ,
`ApprovedBy` VARCHAR( 100 ) NOT NULL ,
`AuthorisedSignatory` VARCHAR( 100 ) NOT NULL
) ENGINE = InnoDB 

*/



mysql_query($sql,$con);

mysql_select_db("admin", $con);

 $sql = "INSERT INTO `payment_invoice` (`CompanyName`, `InvoiceNo.`, `Address`, `InvoiceDate`, `Item`, `Description`, `Rate`, `Qty`, `Unit`, `Price`, `Amount`, `ServiceTaxRegNo`, `AmountTotal`, `PanNo.`, `ServiceTax`, `CategoryOfServices`, `EducationCess`, `SecondaryEducationCess`, `ShareOfClame`, `TotalValue`, `InInteger`, `CheckedBy`, `VerifiedBy`, `ForBusinessPartner`, `ApprovedBy`, `AuthorisedSignatory`) VALUES ('$_POST[fname4]','$_POST[fname422]','$_POST[comments]','$_POST[fname42]','$_POST[fname423]','$_POST[fname424]','$_POST[fname425]','$_POST[fname426]','$_POST[fname427]','$_POST[fname428]','$_POST[fname4282]''$_POST[fname43]','$_POST[fname47]''$_POST[fname44]','$_POST[fname48]','$_POST[fname45]','$_POST[fname49]','$_POST[fname410]','$_POST[fname452]','$_POST[fname4102]','$_POST[fname41025]','$_POST[fname41022]''$_POST[fname41023]''$_POST[fname41024]','$_POST[fname410232]','$_POST[fname410252]')";





if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "Congrats! You hav Sucessfully Submitted your information";


$result = mysql_query("SELECT * FROM payment_invoice");

echo "<table border='1'>
<tr>
<th>CompanyName</th>
<th>InvoiceNo</th>
<th>Address</th>
<th>InvoiceDate</th>
<th>Item</th>
<th>Description</th>
<th>Rate</th>
<th>Qty</th>
<th>unit</th>
<th>Price</th>
<th>Amount</th>
<th>ServiceTaxRegNo</th>
<th>AmountTotal</th>
<th>PanNo.</th>
<th>ServiceTax</th>
<th>CategoryOfServices</th>
<th>EducationCess</th>
<th>SecondaryEducationCess</th>
<th>ShareOfClame</th>
<th>TotalValue</th>
<th>InInteger</th>
<th>CheckedBy</th>
<th>VerifiedBy</th>
<th>ForBusinessPartner</th>
<th>ApprovedBy</th>
<th>AuthorisedSignatory</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['CompanyName'] . "</td>";
  echo "<td>" . $row['InvoiceNo'] . "</td>";
  echo "<td>" . $row['Address'] . "</td>";
  echo "<td>" . $row['InvoiceDate'] . "</td>";
  echo "<td>" . $row['Item'] . "</td>";
  echo "<td>" . $row['Description'] . "</td>";
  echo "<td>" . $row['Rate'] . "</td>";
  echo "<td>" . $row['Qty'] . "</td>";
  echo "<td>" . $row['unit'] . "</td>";
  echo "<td>" . $row['Price'] . "</td>";
  echo "<td>" . $row['Amount'] . "</td>";
  echo "<td>" . $row['ServiceTaxRegNo'] . "</td>";
  echo "<td>" . $row['AmountTotal'] . "</td>";
  echo "<td>" . $row['PanNo.'] . "</td>";
  echo "<td>" . $row['ServiceTax'] . "</td>";
  echo "<td>" . $row['CategoryOfServices'] . "</td>";
  echo "<td>" . $row['EducationCess'] . "</td>";
  echo "<td>" . $row['SecondaryEducationCess'] . "</td>";
  echo "<td>" . $row['ShareOfClame'] . "</td>";
  echo "<td>" . $row['TotalValue'] . "</td>";
  echo "<td>" . $row['InInteger'] . "</td>";
  echo "<td>" . $row['CheckedBy'] . "</td>";
  echo "<td>" . $row['VerifiedBy'] . "</td>";
  echo "<td>" . $row['ForBusinessPartner'] . "</td>";
  echo "<td>" . $row['ApprovedBy'] . "</td>";
  echo "<td>" . $row['AuthorisedSignatory'] . "</td>";
    echo "</tr>";
  }
echo "</table>";

mysql_close($con);
?>

Recommended Answers

All 4 Replies

Hi gurinder16 and welcome to DaniWeb :)

Looks to me like you are missing one or more commas in the values section of your query. Count your columns, then count the items you are inserting - these need to be equal as your error message implies.

have you tried it without the dot in invoicNo

thinks concatenation

darkagn is correct, looks like you are missing multiple commas in the values of the query.

Also, may I suggest that you sanitize the input from the form.. Entering unchecked POST data into your database is asking for trouble.

Member Avatar for diafol

darkagn is correct, looks like you are missing multiple commas in the values of the query.

Also, may I suggest that you sanitize the input from the form.. Entering unchecked POST data into your database is asking for trouble.

Asking? Positively inviting! Mwahahaahaaa.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.