Jump to content

Recommended Posts

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;
?>

 

Link to comment
https://forums.phpfreaks.com/topic/236713-not-deleting/
Share on other sites

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.
}

Link to comment
https://forums.phpfreaks.com/topic/236713-not-deleting/#findComment-1216827
Share on other sites

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."'");

 

Link to comment
https://forums.phpfreaks.com/topic/236713-not-deleting/#findComment-1216861
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.