Jump to content

[SOLVED] Inserting error


ccrevcypsys

Recommended Posts

I am recieving an error when i try to insert information into my database from my form.

this is the error

Column count doesn't match value count at row 1

this is my code for the insert

<?php
if(isset($_POST['customer_name'])){
	$insert = mysql_query("INSERT INTO `serviceorder` 
	(id, receiving_engineer, Shop_engineer, status, customer_name, emailAddress, address, city, state, zipcode, primaryphone,secondaryphone, servicerequested, laborpreformed, billable_time, customerJobInt, customerSupportInt, warningInt, dateCompleted, signature) 
	VALUES 
	('',
	'".$_POST['receiving_engineer']."',
	'".$_POST['Shop_engineer']."',
	'".$_POST['status']."',
	'".$_POST['customer_name']."',
	'".$_POST['emailAddress']."',
	'".$_POST['address']."',
	'".$_POST['city']."',
	'".$_POST['state']."',
	'".$_POST['zipcode']."',
	'".$_POST['primaryphone']."',
	'".$_POST['secondaryphone']."',
	'".$_POST['servicerequested']."',
	'".$_POST['laborpreformed']."',
	'".$_POST['billable_time']."',
	'".$_POST['customerJobInt']."',
	'".$_POST['customerSupportInt']."',
	'".$_POST['warningInt']."',
	'".$date."'
	'".$_POST['signature']."'
	)") 
	or die(mysql_error());
	if($insert == TRUE){
	header("Location: index.php?p=13");
	}
}
?>

and here is the code for my form (its a big form but here you go)

<form action="" class="serviceOrder" enctype="multipart/form-data" method="post">
<div class="header">
    	<span class="logo">
        </span>
        <span class="topbody">
        <h3>Service Order</h3><p style="float:right; margin-right:70px;<?php if($mainquery['sstatus']=="Open"){ echo "color:#38e816;"; }elseif($mainquery['status']=="Closed"){ echo "color:#e81616;"; }?> margin-top:30px;">Status:<input type="hidden" name="status" value="<?php if($mainquery==TRUE){echo $mainquery['status'];}else{ echo "Open"; } ?>" /><?php if(!$_GET['id']){ echo "New"; }else{ echo $mainquery['status']; }?>
        
        </p>
        </span>
    </div>
<div class="main">
<?php echo $msg; ?>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
    	<tr>
        <td>Service Order: <?php echo $mainquery['id']; ?></td><td>Receiving Engineer:<select name="receiving_engineer">
<?php 
$Equery = "SELECT * FROM `engineers`";
$engineerQ = mysql_query($Equery);

while ($engineer = mysql_fetch_array($engineerQ, MYSQL_ASSOC)){ ?>
        <option value="<?php echo $engineer['id']; ?>"><?php echo $engineer['name']; ?></option>
        <?php } ?>
        </select></td><td>Shop Engineer:<select name="Shop_engineer">
<?php 
$query = "SELECT * FROM `engineers`";
$engineerS = mysql_query($query);
while ($engineers = mysql_fetch_array($engineerS, MYSQL_ASSOC)){ ?>
        <option value="<?php echo $engineers['id']; ?>"><?php echo $engineers['name']; ?></option>
        <?php } ?>
        </select></td>
        </tr>
    	<tr class="tdhead"><td colspan="3">Client Information</td></tr>
        <tr>
        	<td valign="top" colspan="2">
            <div id="inputTitle">Customer Name:</div>
            <input type="text" name="customer_name" class="input" value="<?php echo $row['customer_name']; ?>" />
            </td><td colspan="1">
            <div id="inputTitle">Email Address:</div>
            <input type="text" name="emailAddress" class="input" value="<?php echo $row['emailAddress']; ?>" />
            </td>
        </tr>
        <tr>
        	<td colspan="3">
            <div id="inputTitle">Address:</div>
            <input type="text" name="address" class="input" value="<?php echo $row['address']; ?>" />
            </td>
       	</tr>
        <tr>
        	<td>
            <div id="inputTitle">City:</div>
            <input type="text" name="city" class="input" value="<?php echo $row['city']; ?>" />
            </td><td>
            <div id="inputTitle">State:</div>
            <input type="text" name="state" class="input" value="<?php echo $row['state']; ?>" />
            </td><td>
            <div id="inputTitle">Zip Code:</div>
            <input type="text" name="zipcode" class="input" value="<?php echo $row['zipcode']; ?>" />
            </td>
        </tr>
        <tr>
        	<td>
            <div id="inputTitle">Primary Phone:</div>
            <input type="text" name="primaryphone" class="input" value="<?php echo $row['primaryphone']; ?>" />
            </td><td></td><td>
            <div id="inputTitle">Secondary Phone:</div>
            <input type="text" name="secondaryphone" class="input" value="<?php echo $row['secondaryphone']; ?>" />
            </td>
        </tr>
        <tr>
        	<td class="tdhead" colspan="3">Service Requested By Customer</td>
        </tr>
        <tr>
        	<td colspan="3">
            <select name="addServ" id="addServ"  onchange="if(this.value=='1'){document.getElementById('textArea').style.display='none';document.getElementById('checkbox').style.display='';}else{document.getElementById('textArea').style.display='';document.getElementById('checkbox').style.display='none';}">
<option value="1">Automated Input</option>
<option value="2">Manual Input</option>
</select>
<div id="checkbox">
<?php 
$query = "SELECT * FROM `serviceRequested`";
$result = mysql_query($query);
?> <?php 
while ($service = mysql_fetch_array($result, MYSQL_ASSOC)){ ?>
		 <input type="checkbox" name="servicerequested" value="<?php echo $service['serviceName']; ?>" ><?php echo $service['serviceName']." - ".$service['description']; ?>
		 <?php } ?></div>

            <textarea name="servicerequested" id="textArea" style="display:none;" class="textArea" cols="80" rows="10">
            
            </textarea>
            
            </td>
        </tr>
        <tr>
        	<td class="tdhead" colspan="1">Customer Job Approval</td><td class="tdhead" colspan="2">Customer Statement</td>
        </tr>
        <tr>
        	<td colspan="1" align="center"><p style="overflow-y:scroll; height:125px;"><strong>Acknowlegement:</strong><br />I have read and understand the terms and conditions as set forth in this document and herby authorize the work I have requested on this service order to be preformed. I also understand when authorized repairs along with necessary meterials are completed, an express repairmen's lien is herby acknowleged on equipment to secure the amount of repair thereto.</p>Initials: <input name="customerJobInt" value="" type="text" class="input" maxlength="2" style="width:20px; background:#FFFF66;" /></td><td colspan="2" align="center">
        	<p style="overflow-y:scroll; height:125px;">An estimate where requested or required for repair and parts necessary for a specific job may be given to the customer by the service dealer in writing, and the service dealer may not charge for work done or parts supplied in excess of the estimate without prior consent of the customer. The service dealer may charge a reasonable fee for making the estimate. For information, contact your state's Bureau of Repair Services, Department of Consumer Affairs.</p> Initials: <input name="customerSupportInt" value="" type="text" class="input" maxlength="2" style="width:20px; background:#FFFF66;" /></td>
        </tr>
        <tr>
        	<td class="tdhead" colspan="3"><strong>WARNING</strong></td>
        </tr>
        <tr>
        	<td colspan="3" align="center"><p style="font-weight:bold; font-size:16px; text-align:center;">WE CANNOT BE RESPONSIBLE FOR DATA ON HARD DISK!</p>Initials: <input name="warningInt" value="" maxlength="2" type="text" class="input" style="width:20px; background:#FFFF66;" /></td><td colspan="2">
        </tr>
        <tr>
        	<td class="tdhead" colspan="2">Labor Performed</td><td class="tdhead" colspan="1">Billable Time</td>
        </tr>
        <tr>
        	<td colspan="2"><textarea name="laborperformed" class="textArea" cols="60" rows="10"></textarea></td>
            <td><textarea name="billable_time" cols="15" class="textArea" rows="10"></textarea></td>
        </tr>
        <tr><td colspan="2"><div id="inputTitle">Customer's Signature & Date:</div>
</td><td class="tdhead">Total Labor Hours</td></tr>
        <tr>
        	<td colspan="2" valign="top">
            <input type="text" name="signature" class="input" style="width:80%; background:#FFFF66;" value="<?php echo $row['emailAddress']; ?>" /><input name="Month" value="MM" maxlength="2" type="text" class="input" style="width:20px; background:#FFFF66;" />-<input name="Month" value="DD" maxlength="2" type="text" class="input" style="width:20px; background:#FFFF66;" />-<input name="Year" maxlength="4" value="YYYY" type="text" class="input" style="width:30px; background:#FFFF66;" />
            </td>
            <td valign="top">
            <input type="text" name="totalLaborHours" class="input" style="" value="<?php echo $row['totalLaborHours']; ?>" />
            </td>
        </tr>
        <tr>
        <td> </td>
        </tr>
        <tr>
        	<td colspan="3"><input type="submit" class="input" style="height:20px; font-weight:bolder;" value="Save Information" /></td>
        </tr>
    </table>
</form>

Link to comment
Share on other sites

You are missing the comma after $date in your values.

 

Based on what he said

 

try

 

<?php
if(isset($_POST['customer_name'])){
	$insert = mysql_query("INSERT INTO `serviceorder` 
	(id, receiving_engineer, Shop_engineer, status, customer_name, emailAddress, address, city, state, zipcode, primaryphone,secondaryphone, servicerequested, laborpreformed, billable_time, customerJobInt, customerSupportInt, warningInt, dateCompleted, signature) 
	VALUES 
	('',
	'".$_POST['receiving_engineer']."',
	'".$_POST['Shop_engineer']."',
	'".$_POST['status']."',
	'".$_POST['customer_name']."',
	'".$_POST['emailAddress']."',
	'".$_POST['address']."',
	'".$_POST['city']."',
	'".$_POST['state']."',
	'".$_POST['zipcode']."',
	'".$_POST['primaryphone']."',
	'".$_POST['secondaryphone']."',
	'".$_POST['servicerequested']."',
	'".$_POST['laborpreformed']."',
	'".$_POST['billable_time']."',
	'".$_POST['customerJobInt']."',
	'".$_POST['customerSupportInt']."',
	'".$_POST['warningInt']."',
	'".$date."',
	'".$_POST['signature']."'
	)")
	or die(mysql_error());
	if($insert == TRUE){
	header("Location: index.php?p=13");
	}
}
?>

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.