0

Can anyone assist me. I keep getting and error stating that the Column count doesnt match row 1. I have counted all of my fields and referenced all of them but still no dice.

$con=mysql_connect($host, $username, $pass);
if(!$con)
{
    die("Could Not Connect: ".mysql_error());
}
mysql_select_db($db);


$CustLName=$_POST['CustLName'];
$CustFName=$_POST['CustFName'];
$CBR=$_POST['CBR'];
$AcctNum=$_POST['AcctNum'];
$CustCode=$_POST['CustCode'];
$SourceTN=$_POST['SourceTN'];
$SSID=$_POST['SSID'];
$AcctType=$_POST['AcctType'];
$AuthSys=$_POST['AuthSys'];
$CSRSentID=$_POST['CSRSentID'];
$EscSentID='ap608u';
$Issue=$_POST['Issue'];
$EscNum=date('U');
$Program=$_POST['Program'];
if(isset($_POST['Submit']))
{
    $addNew=mysql_query("INSERT INTO $mirtable ( ID, EscNum , EscSentID, CSRSentID, CustFName, CustLName, AcctNum, AcctType, CustCode, Issue, STN, AuthSys, SSID, CBR, Program) VALUES('', '$EscNum', '$EscSentID', '$CSRSentID', '$CustFName', '$CustLName', '$AcctNum,' '$AcctType', '$CustCode', '$Issue', '$SourceTN', '$AuthSys', '$SSID', '$CBR', '$Program')") or die ("Error in query: .\n\nQuery: $addNew\n\nError: " .mysql_error());
}

Edited by diafol: appy code tags

5
Contributors
4
Replies
14
Views
5 Years
Discussion Span
Last Post by doubleN
1

When using the insert statement, there is no need to include the "ID" field. Since your database has auto encriment, it will add it for you automatically. So take out the "ID" in the INSERT statement and '' in the VALUES.

0

I ran into the same error.
What I did was break the SQL statement up and not save it all in one go. Use the INSERT to place the first name, last name, CBR, and account numbers. Then use UPDATE to fill in the remaining information.

FYI - You don't need to transfer your POST variables into different variables to save them into a database, you can save the directly to your database and elimate that step. Move the '' to the front and end of the variable
Example: '$_POST[CustLName]' *INSTEAD OF* $_POST['CustLName']

0

The problem is that the comat after

'$AcctNum,'

is not out. So MySQL engine thing that you want to store less than the column you define. Set it like this

'$AcctNum',

Hope this helpful for other developers. Excuse my english, my language is french

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.