Jump to content

[SOLVED] Query problem


bhavin_85

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.