Jump to content

[SOLVED] yet another mySQL error....


sr20rps13

Recommended Posts

Hey guys, sorry for the bother.

 

<html>
<head>
<title>Order Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
if(isset($_POST['add']))
{

include 'mysql_connect.php';

$customer_number = $_POST['customer_number'];
$comp_brand = $_POST['comp_brand'];
$comp_model = $_POST['comp_model'];
$comp_serial_number = $_POST['comp_serial_number'];
$comp_processor = $_POST['comp_processor'];
$comp_hdd_size = $_POST['comp_hdd_size'];
$comp_ram = $_POST['comp_ram'];
$comp_problem = $_POST['comp_problem'];
$repair_price = $_POST['repair_price'];
$date_of_order = $_POST['date_of_order'];
$order_status = $_POST['order_status'];

$query = "INSERT INTO order_data
(customer_number, comp_brand, comp_model, comp_serial_number, comp_processor, comp_hdd_size, comp_ram, comp_problem, repair_price, date_of_order)
values( '$customer_number', '$comp_brand', '$comp_model', '$comp_serial_number', '$comp_processor', '$comp_hdd_size', '$comp_ram', '$comp_problem', '$repair_price', '$date_of_order', '$order_status',)";

mysql_query($query) or die (mysql_error());

$query = "FLUSH PRIVILEGES";
mysql_query($query) or die (mysql_error());

include 'mysql_close.php';
echo "New customer added";
}
else
{
?>

<form method="post">
<table width="400" border="0" cellspacing="1" cellpadding="2">

<tr> 
<td width="100">Customer number:</td>
<td><input name="customer_number" type="text" id="customer_number"></td>
</tr>
<tr> 
<td width="100">Computer brand:</td>
<td><input name="comp_brand" type="text" id="comp_brand"></td>
</tr>
<tr> 
<td width="100">Computer model:</td>
<td><input name="comp_model" type="text" id="comp_model"></td>
</tr>
<td width="100">Computer serial number:</td>
<td><input name="comp_serial_number" type="text" id="comp_serial_number"></td>
</tr>
<tr> 
<td width="100">Computer processor:</td>
<td><input name="comp_processor" type="text" id="comp_processor"></td>
</tr>
<tr> 
<td width="100">Computer HDD size:</td>
<td><input name="comp_hdd_size" type="text" id="comp_hdd_size"></td>
</tr>
<td width="100">Computer Ram size:</td>
<td><input name="comp_ram" type="text" id="comp_ram"></td>
</tr>
<tr> 
<td width="100">Problem:</td>
<td><input name="comp_problem" type="text" id="comp_problem"></td>
</tr>
<tr> 
<td width="100">Repair cost:</td>
<td><input name="repair_price" type="text" id="repair_price"></td>
</tr>
<td width="100">Date:</td>
<td><input name="date_of_order" type="text" id="date_of_order"></td>
</tr>
<tr> 
<td width="100">Order status:</td>
<td><input name="order_status" type="text" id="order_status"></td>
</tr>

<tr> 
<td width="100"> </td>
<td><input name="add" type="submit" id="add" value="Add customer"></td>
</tr>
</table>
</form>
<?php
}
?>
</body>
</html>

 

I get the error

Column count doesn't match value count at row 1

when I try submitting stuff to the database with that page.

Link to comment
Share on other sites

well i think it might be a very simple error

replace:

$query = "INSERT INTO order_data
(customer_number, comp_brand, comp_model, comp_serial_number, comp_processor, comp_hdd_size, comp_ram, comp_problem, repair_price, date_of_order)
values( '$customer_number', '$comp_brand', '$comp_model', '$comp_serial_number', '$comp_processor', '$comp_hdd_size', '$comp_ram', '$comp_problem', '$repair_price', '$date_of_order', '$order_status',)";

 

With:

$query = "INSERT INTO order_data
(customer_number, comp_brand, comp_model, comp_serial_number, comp_processor, comp_hdd_size, comp_ram, comp_problem, repair_price, date_of_order)
values( '$customer_number', '$comp_brand', '$comp_model', '$comp_serial_number', '$comp_processor', '$comp_hdd_size', '$comp_ram', '$comp_problem', '$repair_price', '$date_of_order', '$order_status')";

there is an extra comma in yours

i was reviewing the coding over again and it seems that u have no order status table inputed u have the value but no table to put it in....

 

your code stops at date_of_order there should be a order_status table

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.