Jump to content

Column count doesn't match value count at row 1


whare

Recommended Posts

[code]<?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.

?>[/code]

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

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

[code]
<?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.

?>
[/code]

Then wherever you have your form, somewhere add:

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

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