0

Hello to all,
I am trying to solve this problem but i did not find the solution. please help me to find the solution.

Error: Column count doesn't match value count at row 1

<?php 
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("hotel", $con);
$hotelid=$_POST['hotelid'];
$roomid = $_POST['Event'];
$select = "SELECT _discount FROM tblregistration where _hotelid = '$hotelid' ";
$result= mysql_query($select);
$select1="SELECT _cost FROM tblroomregistration where _hotelid = '$hotelid' and _roomid = '$roomid'";
$result1= mysql_query($select1);
$row = mysql_fetch_array($result);

$a= $row['_discount'];


while($row = mysql_fetch_array($result1))
{
$b= $row['_cost'];
}
$c = $b*$a/100;
$d = $c*25/100;

$e = $b-$d;


$select="SELECT * FROM tblroomregistration where _hotelid = '$hotelid' and _roomid = '$roomid'";
$result= mysql_query($select);

while($row = mysql_fetch_array($result))
{
$roomtype = $row['_roomtype'];
$roomtype2 = $row['_roomtype2'];
$cost = $row['_cost'];
}
 
if($_POST[mode]=='Credit Card' and $_POST[agent]!='')
{
$sql="INSERT INTO tblbooking SET _hotelid='$hotelid',
                                 _bookingid = '',
                                 _name='$_POST[name]',
                                 _mail='$_POST[mail]',
                                 _address='$_POST[addres]',
                                 _checkin='$_POST[date1]',
                                 _checkout='$_POSTdate2]',
                                 _tourist='$_POST[Tourist]',
                                 _children='$_POST[child]',
                                 _age='$_POST[age]',
                                 _roomid='$roomid',
								 _roomtype = '$roomtype',
                                  _roomtype2='$roomtype2',
                                  _cost='$cost',
                                  _referenceid='$_POST[agent]',
                                 _mode='$_POST[mode]',
                                 _typebankname='$_POST[Creditname]',
                                 _cardno='$_POST[ccnumber]',
                                 _expirymonth='$_POST[month]',
                                 _expiryear='$_POST[year]',
                                  cvv = '$_POST[cvv]',
                                  _billingaddress='$_POST[adress]',
                                  _state='$_POST[state]',
                                 _city='$_POST[city]',
                                _zipcode='$_POST[pin]',
                                _status='0'";
                                 
echo "<b>Your bill is $cost</b>";
}
else 
{
$sql="INSERT INTO tblbooking(_hotelid,_bookingid,_name,_mail,_address,_checkin,_checkout,_tourist,_children,_age,_roomid,_roomtype,_roomtype2,_cost,_referenceid,_mode,_typebankname,_cardno,_expirymonth,_expiryear,cvv,_billingaddress,_state,_city,_zipcode,_status)
VALUES
('$_POST[hotelid]','','$_POST[name]','$_POST[mail]','$_POST[addres]','$_POST[date1]','$_POST[date2]','$_POST[Tourist]','$_POST[child]','$_POST[age]','$roomid','$roomtype','$roomtype2','$e','$_POST[agent]','$_POST[mode]','$_POST[Creditname]','$_POST[ccnumber]',
'$_POST[month]','$_POST[year]','$_POST[cvv]','$_POST[adress]','$_POST[state]','$_POST[city]','$_POST[pin]','0')";
echo "<b>Your bill is $e</b>";
}

if($_POST[mode]=='Debit Card' and $_POST[agent]!="")
{
$sql="INSERT INTO tblbooking(_hotelid,_name,_mail,_address,_checkin,_checkout,_tourist,_children,_age,_roomid,_roomtype,_roomtype2,_cost,_referenceid,_mode,_typebankname,_cardno,_expirymonth,_expiryear,cvv,_billingaddress,_state,_city,_zipcode,_status)
VALUES
('$_POST[hotelid]','$_POST[name]','$_POST[mail]','$_POST[addres]','$_POST[date1]','$_POST[date2]','$_POST[Tourist]','$_POST[child]','$_POST[age]','$roomid','$roomtype','$roomtype2','$cost','$_POST[agent]','$_POST[mode]','$_POST[debitname]','$_POST[dcnumber]','$_POST[mnth]','$_POST[yer]','$_POST[Cvv]','$_POST[adress]','$_POST[State]','$_POST[City]','$_POST[Pin]','0')";
}
else
{
$sql="INSERT INTO tblbooking(_hotelid,_name,_mail,_address,_checkin,_checkout,_tourist,_children,_age,_roomid,_roomtype,_roomtype2,_cost,_referenceid,_mode,_typebankname,_cardno,_expirymonth,_expiryear,cvv,_billingaddress,_state,_city,_zipcode,_status)
VALUES
('$_POST[hotelid]','$_POST[name]','$_POST[mail]','$_POST[addres]','$_POST[date1]','$_POST[date2]','$_POST[Tourist]','$_POST[child]','$_POST[age]','$roomid','$roomtype','$roomtype2','$e','$_POST[agent]','$_POST[mode]','$_POST[debitname]','$_POST[dcnumber]','$_POST[mnth]','$_POST[yer]','$_POST[Cvv]','$_POST[adress]','$_POST[State]','$_POST[City]','$_POST[Pin]','0')";
}

if($_POST[mode]=='Bank' and $_POST[agent]!="")
{
$sql="INSERT INTO tblbooking(_hotelid,_name,_mail,_address,_checkin,_checkout,_tourist,_children,_age,_roomid,_roomtype,_roomtype2,_cost,_mode,_referenceid,_typebankname)
VALUES
('$_POST[hotelid]','$_POST[name]','$_POST[mail]','$_POST[addres]','$_POST[date1]','$_POST[date2]' ,'$_POST[Tourist]','$_POST[child]','$_POST[age]','$cost','$_POST[agent]','$_POST[mode]','$_POST[Bankname]')";
}
else
{
$sql="INSERT INTO tblbooking(_hotelid,_name,_mail,_address,_checkin,_checkout,_tourist,_children,_age,_roomid,_roomtype,_roomtype2,_cost,_mode,_referenceid,_typebankname)
VALUES
('$_POST[hotelid]','$_POST[name]','$_POST[mail]','$_POST[addres]','$_POST[date1]','$_POST[date2]' ,'$_POST[Tourist]','$_POST[child]','$_POST[age]','$e','$_POST[agent]','$_POST[mode]','$_POST[Bankname]')";
}
if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }

$sql1 = "update tblroomregistration set _status = '1' where _status = '0' and _roomid = '$roomid'";
if (!mysql_query($sql1,$con))
  {
  die('Error: ' . mysql_error());
  }

$select = "SELECT _bookingid FROM tblbooking where _hotelid = '$hotelid' order by _hotelid desc";

$result= mysql_query($select);
while($row = mysql_fetch_array($result))
{

$book_id = $row['_bookingid'];
}
if($_POST[agent]!= "")
{
$sql2 = "insert into tblagent(_hotelid,_bookingid,_agentid,_commission) values('$_POST[hotelid]','$book_id','$_POST[agent]','$d')";
if (!mysql_query($sql2,$con))
  {
  die('Error: ' . mysql_error());
  }
}
else
{
echo "";
}
$sql3 = "insert into tblagent(_hotelid,_bookingid,_agentid,_commission) values('$_POST[hotelid]','$book_id','$_POST[agent]','$d')";
if (!mysql_query($sql3,$con))
  {
  die('Error: ' . mysql_error());
  }
//header("location:booking.php?_hotelid=$hotelid ");
mysql_close($con)
?>
2
Contributors
1
Reply
6
Views
5 Years
Discussion Span
Last Post by pritaeas
0

Error: Column count doesn't match value count at row 1

This error is caused by something like this:

INSERT INTO table (col1, col2) VALUES ('val1', 'val2', 'val3')

so make sure the count matches before and after VALUES.

Another issue is on line 41. The query says INSERT INTO, but its syntax is for an UPDATE.

Edited by pritaeas: n/a

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.