Jump to content


Photo

Column count doesn't match value count at row 1


  • Please log in to reply
5 replies to this topic

#1 whare

whare
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 06 August 2006 - 04:20 PM

sorry new at php and dont understand the error

Column count doesn't match value count at row 1



Anybody?

#2 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 06 August 2006 - 04:28 PM

Can you post you code?

#3 whare

whare
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 06 August 2006 - 04:32 PM

<?php
include "db.php";

$pilotid = $_POST['pilotid'];
$flightnumber = $_POST['flightnumber'];
$depair = $_POST['depair'];
$deptime = $_POST['deptime'];
$arair = $_POST['arair'];
$artime = $_POST['artime'];
$flighttime = $_POST['flighttime'];
$flightinfo = $_POST['flightinfo'];
$username = $_POST['username'];
$password = $_POST['password'];

$result = mysql_query("SELECT * FROM users")or die(mysql_error());  

$row = mysql_fetch_array( $result );

//$password = md5($password);

$flighttotal = $flighttime + $row['flighttotal'];

//if($password == $row['password']){
//	}

//if($_SESSION['username'] == $username){
//	}
$sql = mysql_query("INSERT INTO pirep (pilotid, flightnumber, 
        depair, deptime, arair, artime, flighttime, flightinfo, pirep_date, flighttotal)
        VALUES('$pilotid','$flightnumber','$depair','$deptime','$arair','$artime','$flighttime','$flightinfo','$flighttotal')") 
        or die (mysql_error());
//	echo "Thank you for your pirep.<br />Your information has been sent to our database pending review from our team.

?>

now the areas that have "//" i am alos trying to get working but comming up with other errors but one thing at a time :)

#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 06 August 2006 - 04:36 PM

You're trying to insert 9 values into 10 fields. The number of values needs to be the same as the number for fields.

Ken

#5 whare

whare
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 06 August 2006 - 04:38 PM

ohh right i c i think so how do i use the "pirep_date one then coz that needs to be filled when the file is run??

#6 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 06 August 2006 - 04:48 PM

Make a hidden field for it, that has the value of whatever it will be. For example:

<?php
include "db.php";

$pilotid = $_POST['pilotid'];
$flightnumber = $_POST['flightnumber'];
$depair = $_POST['depair'];
$deptime = $_POST['deptime'];
$arair = $_POST['arair'];
$artime = $_POST['artime'];
$flighttime = $_POST['flighttime'];
$flightinfo = $_POST['flightinfo'];
$pirep_date = $_POST['pirep_date'];
$username = $_POST['username'];
$password = $_POST['password'];

$result = mysql_query("SELECT * FROM users")or die(mysql_error());  

$row = mysql_fetch_array( $result );

//$password = md5($password);

$flighttotal = $flighttime + $row['flighttotal'];

//if($password == $row['password']){
//	}

//if($_SESSION['username'] == $username){
//	}
$sql = mysql_query("INSERT INTO pirep (pilotid, flightnumber, 
        depair, deptime, arair, artime, flighttime, flightinfo, pirep_date, flighttotal)
        VALUES('$pilotid','$flightnumber','$depair','$deptime','$arair','$artime','$flighttime','$flightinfo','$pirep_date','$flighttotal')") 
        or die (mysql_error());
//	echo "Thank you for your pirep.<br />Your information has been sent to our database pending review from our team.

?>

Then wherever you have your form, somewhere add:

<input type="hidden" name="pirep_date" value="<?php echo date("F, j, Y"); ?>">

With that, the current date (As: Month, Day, Year e.x August, 6, 2006) will be inserted into pirep_date.

None the less, if you are inserting a value, you need to have a field for it.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users