Jump to content


Photo

Table Update


  • Please log in to reply
5 replies to this topic

#1 whare

whare
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 19 August 2006 - 12:05 PM

Hi All

Right im having problems updating a table entry here is the code

<?php

session_start();
include 'config.php';
// Form Field info
$fltnum = $_POST['fltnum'];
$actype = $_POST['actype'];
$depair = $_POST['depair'];
$deptime = $_POST['deptime'];
$arair = $_POST['arair'];
$artime = $_POST['artime'];
$flttime = $_POST['flttime'];
$fltinfo = $_POST['fltinfo'];

$userid = $_SESSION['userid'];



$sql = mysql_query("INSERT INTO pirep (userid, fltnum, actype, depair, deptime, arair, artime, flttime, fltinfo, pirep_date)
        VALUES('$userid','$fltnum','$actype','$depair','$deptime','$arair','$artime','$flttime','$fltinfo', now())")
        or die (mysql_error());

$result = mysql_query("SELECT * FROM pilot WHERE userid='$userid'");
while($row = mysql_fetch_array( $result )) {
$flttot = $row['tothour'];
$totflt = $flttime + $flttot;
}
mysql_query("UPDATE pilot SET tothour='$totflt' WHERE userid='$userid'");
$stat = $_SESSION['userlevel'];
if($stat==0){
	mysql_query("UPDATE pilot SET userlevel='1' WHERE userid='$userid'");
}
	mysql_query("UPDATE pilot SET lastpirep=now() WHERE userid='$userid'");
	echo "Thankyou for your Pirep.";

	$result = mysql_query("SELECT * FROM stats");
	while($row = mysql_fetch_array( $result )) {
$pireps = $row['pireps'];
$hour = $row['hours'];
$pirep1 = $pireps + 1;
$hour1 = $hour + $totflt;
	}
	mysql_query("UPDATE stats SET pirep='$pirep1' AND hours='$hour1'");

?>


now the code does not update the table but also does not return any errors in the code any ideas on this one (mostlily something simple it always is lol

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 19 August 2006 - 12:27 PM

mysql_query("UPDATE stats SET pirep='$pirep1' AND hours='$hour1'");

WHERE what condition??
Legend has it that reading the manual never killed anyone.
My site

#3 whare

whare
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 19 August 2006 - 02:31 PM

oohh I need to have a WHERE codition then ok i better set one then thanx :)

#4 whare

whare
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 19 August 2006 - 03:24 PM

mysql_query("UPDATE stats SET pirep='$pirep1' AND hours='$hour1' WHERE id='1'");

still not working

#5 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 19 August 2006 - 03:29 PM

Try:

$query = "UPDATE stats SET pirep='$pirep1', hours='$hour1' WHERE id='1'";
$result = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query); // useful error message

Legend has it that reading the manual never killed anyone.
My site

#6 whare

whare
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 19 August 2006 - 03:48 PM

That worked loads better

Thank you 

It gave me an error about a typo [as i said in the first post a simple problem lol]

Thanx Alot mate

:)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users