NSW42 Posted May 18, 2011 Share Posted May 18, 2011 Could anyone tell me why this is not deleting the userip and post id from the database at all. Thanks <?php include('dbcon.php'); if($_REQUEST['postId']) { $userip = $_SERVER['REMOTE_ADDR']; mysql_query("update collapsed_likes set likes=likes-1 where post_id= ".$_REQUEST['postId']); mysql_query("delete from collapsed_ip where userip=".$userip." AND post_id = ".$_REQUEST['postId']); $total_likes = mysql_query("SELECT * FROM collapsed_likes where post_id = ".$_REQUEST['postId']." "); $likes = mysql_fetch_array($total_likes); $likes = $likes['likes']; } echo $likes; ?> Quote Link to comment https://forums.phpfreaks.com/topic/236713-not-deleting/ Share on other sites More sharing options...
Pikachu2000 Posted May 18, 2011 Share Posted May 18, 2011 You have no logic in place to report any errors. Separate the query strings from the execution, and echo any query string that causes a query to fail, along with the error it returns. pseudo-code $query = 'SELECT field FROM table'; if( !$result = mysql_query($query) ) { echo "<br>Query string: $query<br>Failed with error: " . mysql_error() . '<br>'; } else { // whatever is to be done for a successful query execution. } Quote Link to comment https://forums.phpfreaks.com/topic/236713-not-deleting/#findComment-1216827 Share on other sites More sharing options...
NSW42 Posted May 18, 2011 Author Share Posted May 18, 2011 Actually there is no errors showing, it is an like unlike script, if you unlike a comment it works, but when you refresh the page it shows unlike again, this is because it is not deleting the userip or post id, and i'm at a loss as to why it wont. Quote Link to comment https://forums.phpfreaks.com/topic/236713-not-deleting/#findComment-1216832 Share on other sites More sharing options...
Pikachu2000 Posted May 18, 2011 Share Posted May 18, 2011 Probably because a query is failing. Please refer to my previous post. Quote Link to comment https://forums.phpfreaks.com/topic/236713-not-deleting/#findComment-1216839 Share on other sites More sharing options...
NSW42 Posted May 18, 2011 Author Share Posted May 18, 2011 Fixed it and thanks anyway Changed this mysql_query("delete from facebook_collapsed_ip where userip=".$userip." AND post_id = ".$_REQUEST['postId']); to this mysql_query("delete from facebook_collapsed_ip where post_id ='".$_REQUEST['postId']."' AND userip ='".$userip."'"); Quote Link to comment https://forums.phpfreaks.com/topic/236713-not-deleting/#findComment-1216861 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.