Jump to content

Not deleting


NSW42

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

Archived

This topic is now archived and is closed to further replies.

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