bhavin_85 Posted April 23, 2007 Share Posted April 23, 2007 HEy guys ive jsut written a query, it worked the first few times i run it but now im getting this error : "Column count doesn't match value count at row 1" ive checked through my DB and its working fun uptil $sql2....any ideas? for($i=0; $i<8;$i++) { if(empty($_POST['description'][$i]) || empty($_POST['item_item_id'][$i]) || empty($_POST['price'][$i])) { continue; } else { $lastid = $lastid; $item_item_id = $_POST['item_item_id'][$i]; $description = addslashes($_POST['description'][$i]); $weight = $_POST['weight'][$i]; $price = $_POST['price'][$i]; $points = $price * 0.1; $sql1="INSERT INTO invoice_items VALUES (0,'$lastid', '$item_item_id', '$description', '$weight', '$price', '$points')"; $query1 = mysql_query($sql1) or die(mysql_error()); $sql2="INSERT INTO points_history VALUES (0,'$cust_id','$points','$date')"; $query2 = mysql_query($sql2) or die(mysql_error()); $sql3="SELECT points FROM points WHERE cust_id='$cust_id'"; $query3=mysql_query($sql3); $row3=mysql_fetch_assoc($query3); $points1=$row3['points']; $newpoints=$points1 + $points; $sql4="UPDATE points SET points='$newpoints' WHERE cust_id='$cust_id'"; $query4=mysql_query($sql4); } Link to comment https://forums.phpfreaks.com/topic/48350-solved-query-problem/ Share on other sites More sharing options...
bhavin_85 Posted April 23, 2007 Author Share Posted April 23, 2007 ive just tried dropping the data in all the tables and th problem is still happening i dont know why ??? ive gotta demo this 2morow so i need 2 sort this ASAP! Link to comment https://forums.phpfreaks.com/topic/48350-solved-query-problem/#findComment-236394 Share on other sites More sharing options...
benjaminbeazy Posted April 23, 2007 Share Posted April 23, 2007 somewhere you are trying to insert more values than columns for a row, try writing your inserts like and you may come across your problem, INSERT INTO tbl_name () VALUES(); Link to comment https://forums.phpfreaks.com/topic/48350-solved-query-problem/#findComment-236395 Share on other sites More sharing options...
mpharo Posted April 23, 2007 Share Posted April 23, 2007 In your inserts you need to specify the columns you want the items inserted into, just like in the above post states also like this.... INSERT INTO table (field1, field2, field3) VALUES ('value1','value2','value3') Link to comment https://forums.phpfreaks.com/topic/48350-solved-query-problem/#findComment-236398 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.