maxudaskin Posted May 9, 2008 Share Posted May 9, 2008 I tell it to change a 1 to a 2 but it ignores the command, if I input deny, instead of changing it to 2, it changes it to 0. <?php if(!$logged_in){ echo 'You are not logged in'; }else{ if($_SESSION['type'] == 1){ $action = $_GET['action']; $pirep = $_GET['pirep']; $admin = 'OOM'.$_SESSION['username'].' '.$_SESSION['name']; $get_user_info = mysql_query("SELECT * FROM pireps WHERE pirepid = '{$pirep}'"); $pid = mysql_fetch_array($get_user_info); $usersql = mysql_query("SELECT * FROM users WHERE pid = '{$pid}'"); $user_array = mysql_fetch_array($usersql); $user = $user_array['fname']." ".$user_array['lname']; $rank = $user_array['rank']; $date = date("Y-m-d H:i:s"); if(!empty($action) || !empty($pirep)){ if($action == 'accept'){ mysql_query("UPDATE `zoomdb`.`pireps` SET `type` = '0' AND `approvedby` = '$admin' AND `approvedatetime` = '$date' WHERE `pireps`.`pirepid` ='{$pirep}' LIMIT 1") or die('ERROR: Application not accepted due to internal error; '.mysql_error()); echo 'PIREP Accepted.'; echo $user_array['email']; $to = $user_array['email']; $subject = "Flight Report Accepted"; $pirep_sql = mysql_query("SELECT * FROM pireps WHERE pirepid = '{$pirep}'"); $pirep_info = mysql_fetch_array($pirep_sql); $message = $rank ." ". $user .", The recent flight report that you have filed has been accepted. Your hours have been updated accordingly. The report was accepted by ".$pirep_info['acceptedby']." on ".$pirep_info['accepteddatetime']; $from = "[email protected]"; $headers = "From: $from"; mail($to,$subject,$message,$headers) or die ("<br /><br /><div class=\"status_message status_error\">ERROR: Email not sent to user.</div>"); }elseif($action == 'deny'){ mysql_query("UPDATE `zoomdb`.`pireps` SET `type` = '2' AND `approvedby` = '$admin' AND `approvedatetime` = '$date' WHERE `pireps`.`pirepid` ='{$pirep}' LIMIT 1") or die('ERROR: Application not accepted due to internal error; '.mysql_error()); echo "Pirep Denied."; }else{ echo 'You have specified an unknown action.'; }} }else{ echo 'You are not a staff member.'; } } ?> Inputs: action=deny&pirep=141 Quote Link to comment https://forums.phpfreaks.com/topic/104787-mysql-disobeying-commands/ Share on other sites More sharing options...
maxudaskin Posted May 9, 2008 Author Share Posted May 9, 2008 And it says Pirep Denied. Quote Link to comment https://forums.phpfreaks.com/topic/104787-mysql-disobeying-commands/#findComment-536418 Share on other sites More sharing options...
radar Posted May 9, 2008 Share Posted May 9, 2008 Give me a few moments and i'll re-write your script for you to see if my way of doing it will work for you... Quote Link to comment https://forums.phpfreaks.com/topic/104787-mysql-disobeying-commands/#findComment-536420 Share on other sites More sharing options...
maxudaskin Posted May 9, 2008 Author Share Posted May 9, 2008 This script is one of my older scripts... which means that I didn't comment it or indent it... or use the more complex functions either... lol. Quote Link to comment https://forums.phpfreaks.com/topic/104787-mysql-disobeying-commands/#findComment-536422 Share on other sites More sharing options...
radar Posted May 9, 2008 Share Posted May 9, 2008 Try this. It is untested, so it might have some errors or something... You might also have to change the strings within the brackets to just a regular string.. but since this isnt the full code, that might not be the case. At any rate, try it and let me know what happens. <?php if (!$logged_in) { echo 'you are not logged in'; } else { if ($_SESSION['type'] == 1) { $_action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; $_pirep = isset($_REQUEST['action']) ? $_REQUEST['pirep'] : ''; $admin = 'OOM'.$_SESSION['username'].' '.$_SESSION['name']; $get_user_info = mysql_query("SELECT * FROM pireps WHERE pirepid = '{$pirep}'"); $pid = mysql_fetch_array($get_user_info); $usersql = mysql_query("SELECT * FROM users WHERE pid = '{$pid}'"); $user_array = mysql_fetch_array($usersql); $user = $user_array['fname']." ".$user_array['lname']; $rank = $user_array['rank']; $date = date("Y-m-d H:i:s"); switch ($_action) { case accept: mysql_query("UPDATE `zoomdb`.`pireps` SET `type` = '0' AND `approvedby` = '$admin' AND `approvedatetime` = '$date' WHERE `pireps`.`pirepid` ='{$pirep}' LIMIT 1") or die('ERROR: Application not accepted due to internal error; '.mysql_error()); echo 'PIREP Accepted.'; echo $user_array['email']; $to = $user_array['email']; $subject = "Flight Report Accepted"; $pirep_sql = mysql_query("SELECT * FROM pireps WHERE pirepid = '{$pirep}'"); $pirep_info = mysql_fetch_array($pirep_sql); $message = $rank ." ". $user .", The recent flight report that you have filed has been accepted. Your hours have been updated accordingly. The report was accepted by ".$pirep_info['acceptedby']." on ".$pirep_info['accepteddatetime']; $from = "[email protected]"; $headers = "From: $from"; mail($to,$subject,$message,$headers) or die ("<br /><br /><div class=\"status_message status_error\">ERROR: Email not sent to user.</div>"); break; case deny: mysql_query("UPDATE `zoomdb`.`pireps` SET `type` = '2' AND `approvedby` = '$admin' AND `approvedatetime` = '$date' WHERE `pireps`.`pirepid` ='{$pirep}' LIMIT 1") or die('ERROR: Application not accepted due to internal error; '.mysql_error()); echo "Pirep Denied."; break; default: echo 'You have specified an unknown action.'; break; } } else { echo 'You are not a staff member.'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/104787-mysql-disobeying-commands/#findComment-536430 Share on other sites More sharing options...
maxudaskin Posted May 9, 2008 Author Share Posted May 9, 2008 It is still being an SOB. Quote Link to comment https://forums.phpfreaks.com/topic/104787-mysql-disobeying-commands/#findComment-536432 Share on other sites More sharing options...
maxudaskin Posted May 9, 2008 Author Share Posted May 9, 2008 Bump... I really need to fix this issue and I am out of Ideas... Quote Link to comment https://forums.phpfreaks.com/topic/104787-mysql-disobeying-commands/#findComment-537192 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.