dudejma Posted August 16, 2011 Share Posted August 16, 2011 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"); Quote Link to comment https://forums.phpfreaks.com/topic/244882-checkboxes/ Share on other sites More sharing options...
phpSensei Posted August 16, 2011 Share Posted August 16, 2011 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()); Quote Link to comment https://forums.phpfreaks.com/topic/244882-checkboxes/#findComment-1257961 Share on other sites More sharing options...
chintansshah Posted August 16, 2011 Share Posted August 16, 2011 Can you paste whole code instead of piece of code. I really need to see $row = mysql_fetch_array($result); $result query of the above code. Quote Link to comment https://forums.phpfreaks.com/topic/244882-checkboxes/#findComment-1257987 Share on other sites More sharing options...
phpSensei Posted August 16, 2011 Share Posted August 16, 2011 Can you paste whole code instead of piece of code. I really need to see $row = mysql_fetch_array($result); $result query of the above code. or he can just code properly... Quote Link to comment https://forums.phpfreaks.com/topic/244882-checkboxes/#findComment-1257989 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.