unemployment Posted April 20, 2011 Share Posted April 20, 2011 I have created a lightbox where you can accept of deny friends. Each friend that is displayed has approved or deny buttons next to them. The approve button has a name like... approverequest[2] The delete button has a name like... denyrequest[2] where 2 is the users id My problem is that I can't get the data to update in mysql. Am I going about this the wrong way? if (isset($_POST['acceptrequest'])) { if (is_array($_POST['acceptrequest'])) { $keys = array_keys($_POST['acceptrequest']); $id = $keys[0]; $sql = "UPDATE `partners` SET `approved` = 1, `approved_date` = NOW() WHERE `user_id` = '$id'"; header("Location: " . $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'] ); } } else if (isset($_POST['denyrequest'])) { if (is_array($_POST['denyrequest'])) { $keys = array_keys($_POST['denyrequest']); $id = $keys[0]; $sql = "UPDATE `partners` SET `approved` = -1, `approved_date` = NOW() WHERE `user_id` = '$id'"; header("Location: " . $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'] ); } } if (isset($sql) && !empty($sql)) { mysql_query($sql); } Quote Link to comment https://forums.phpfreaks.com/topic/234252-accept-of-deny-lighbox-buttons/ Share on other sites More sharing options...
kney Posted April 20, 2011 Share Posted April 20, 2011 I think you forgot something <?php $sql = "UPDATE `partners` SET `approved` = 1, `approved_date` = NOW() WHERE `user_id` = '$id'"; // after the previous line, you have to do this next line to update ur table mysql_query($sql); ?> Quote Link to comment https://forums.phpfreaks.com/topic/234252-accept-of-deny-lighbox-buttons/#findComment-1203978 Share on other sites More sharing options...
unemployment Posted April 20, 2011 Author Share Posted April 20, 2011 I think you forgot something <?php $sql = "UPDATE `partners` SET `approved` = 1, `approved_date` = NOW() WHERE `user_id` = '$id'"; // after the previous line, you have to do this next line to update ur table mysql_query($sql); ?> I don't think so because I am using... if (isset($sql) && !empty($sql)) { mysql_query($sql); } UPDATE: I forgot to add in friend_id if (isset($_POST['acceptrequest'])) { if (is_array($_POST['acceptrequest'])) { $keys = array_keys($_POST['acceptrequest']); $id = $keys[0]; $sql = "UPDATE `partners` SET `approved` = 1, `approved_date` = NOW() WHERE `user_id` = '$id' AND `friend_id` = {$user_info['uid']}"; header("Location: " . $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'] ); } } else if (isset($_POST['denyrequest'])) { if (is_array($_POST['denyrequest'])) { $keys = array_keys($_POST['denyrequest']); $id = $keys[0]; $sql = "UPDATE `partners` SET `approved` = -1, `approved_date` = NOW() WHERE `user_id` = '$id' AND `friend_id` = {$user_info['uid']}"; header("Location: " . $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'] ); } } Quote Link to comment https://forums.phpfreaks.com/topic/234252-accept-of-deny-lighbox-buttons/#findComment-1203980 Share on other sites More sharing options...
kenrbnsn Posted April 20, 2011 Share Posted April 20, 2011 You're not even getting to <?php if (isset($sql) && !empty($sql)) { mysql_query($sql); } ?> Since you're using the header function to go to another page before that point is reached. Ken Quote Link to comment https://forums.phpfreaks.com/topic/234252-accept-of-deny-lighbox-buttons/#findComment-1204063 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.