Jump to content

Checkboxes..


dudejma

Recommended Posts

So I have this code, and it set's the PIREP's status to 1, but it doesn't add the flight time or change the virtual location for any flights after the first one. Here's the code. Any help would be great. Thanks guys!

 

if (isset($_POST['approve'])) {

$row = mysql_fetch_array($result);

array_map('intval',$id);
    $id = implode(',',$id);

$pilotid = $row['pilotID'];

$sql2 = "SELECT hours FROM users WHERE pilotID = '$pilotid'";

$result2 = mysql_query($sql2);

$oldHours = mysql_result($result2, 0);

$newHours = $oldHours + $row['flightTime'];

$arrival = $row['arrival'];

$expDate = date("n/j/Y", strtotime("+30 days"));

$sql3 = "UPDATE users SET hours = '$newHours', virtualLocation = '$arrival', expDate = '$expDate' WHERE pilotID = '$pilotid'";

$result3 = mysql_query($sql3);

$sql4 = "UPDATE pireps SET status = '1' WHERE id IN ($id)";

$result4 = mysql_query($sql4)
or die("An error has occured. Please contact the webmaster with the following error: " . mysql_error());

header("Location: pireps.php");

Link to comment
https://forums.phpfreaks.com/topic/244882-checkboxes/
Share on other sites

You need to clean up your code and do things properly, using conditional statements to check wether the sql went through or not, otherwise output an error or something..

 

 

or even, to debug your code, add the die(mysql_error());

$result2 = mysql_query($sql2) or die(mysql_error());

 

Link to comment
https://forums.phpfreaks.com/topic/244882-checkboxes/#findComment-1257961
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.