For some strange reason I cannot insert a username into the database, but when I change the value into any integer it works once I click like, it works.
$postid = $_POST['postid'];
$userid = $_GET['username'];
$result = mysqli_query($dbh,"SELECT * FROM user_images WHERE id=$postid");
$row = mysqli_fetch_array($result);
$n = $row['likes'];
mysqli_query($dbh,"INSERT INTO likes(username, postid) VALUES($userid, $postid)");
mysqli_query($dbh,"UPDATE user_images SET likes=$n+1 WHERE id=$postid");
echo $n+1;
exit();