that's fine. was just trying to show the relevant part but I can paste the whole index.php here:
<!doctype html>
<?php
error_reporting(E_ALL); ini_set('display_errors', 1); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
session_start();
?>
<html>
<head>
<?php
include('header.php');
?>
<!--<script>
var username = $('.liked_button').click(function() {
var username = $(this).data('username'),
var image_info = $(this).data('image');
$.ajax ({type:"POST", url:'like_button.php', data:{user:username, image:image_info}, success:function()
});
}
</script>-->
<!--<script>
$(document).ready(function() {
$(".like_button").click(function(){
var like = $(this);
$.ajax ({ url:"liked_button.php", type:"POST", data:{}, async:false, success:function(data) {
like.replaceWith("<button type='button' class='button_pressed'>Liked</button>")
}});
});
});
</script>-->
<link type="text/css" rel="stylesheet" href="index.css">
</head>
<body>
<?php
//dispay the images that the users upload
$conn = mysqli_connect("localhost","root","") or die ("No SQLI");
mysqli_select_db($conn, "sample") or die ("No DB");
$sqli = "SELECT * FROM `photos` ORDER BY `id` DESC";
$result = mysqli_query($conn, $sqli) or die ("No query");
while($row = mysqli_fetch_assoc($result))
{
$username = $_SESSION['id'];
$title = $row['title'];
$description = $row['description'];
$image_name = $row['image_name'];
$random_directory = $row['random_direc'];
$date = date('M/d/Y');
$liked_img_loc = "";//prevent undefined index error
$image_info = "http://localhost/splindr_2.0/photos/$random_directory/$image_name";
//run query to get likes
$sqli = "SELECT * FROM `likes` WHERE `liked_img_loc` = '$liked_img_loc' ";
//query results
$likes_result = mysqli_query($conn, $sqli) or die ("No query");
$like_count = '0' ; $unlike_count = '0';
while($likes_row = mysqli_fetch_assoc($likes_result)) {
if($likes_row['liked_unliked'] == 0) {
$unlikeCount++;
} else {
$like_count++;
}
}
}
?>
<div id='contentWrapper'>
<div class='photo'>
<div class='actual_image'>
<img src='<?php echo $image_info; ?>'>
</div>
<div class='like_system'>
<form action="liked_button.php" method='GET' name='like_form' class='form'>
<img src="http://i.imgur.com/pMmYaYM.jpg" class="like_button button" name="like_button">
<input type='hidden' name='hidden_image' class='hidden_image' value='<?php echo $image_info; ?>'>
<input disabled type='text' name='total_likes' class='total_likes' value='0'>
</form>
<a style='color: #2e4987;text-decoration:none' href="http://www.twitter.com/share?url=$image_info&hashtags=Splindr, CheckThisOut">
<img class='twitter_button button' name='twitter_button' src="http://i.imgur.com/hKFKJoj.jpg"></a>
<form action="comment_button.php" method="GET" name='comment_form' class='form'>
<img class="show_comment button" name="show_comment" src="http://i.imgur.com/8azoFjh.jpg">
<input disabled type='text' class='comment_count' name='comment_count' value='0'>
<input type='hidden' name='hidden_comment' class='hidden_comment button' value='<?php echo $image_info; ?>'>
</form>
<img class="delete_button button" name="delete_button" src="http://i.imgur.com/wKZu2H1.jpg">
</div>
<div class='info_wrapper'>
<div class='info_header'>Title: <?php echo $title; ?>   By: <?php echo $username; ?>   Date: <?php echo $date; ?></div>
<div class='description'><?php echo $description; ?></div>
</div>
<div class='comment_wrapper'>
<div class='close_comment'>[close comments]</div>
<div class='comment_box_wrapper'>
<div class='comment_box'>
<div class='profile_pic'><img src='https://i.imgur.com/1MkFvhU.png'></div>
<div class='actual_comment'>Comment goes here...</div>
</div>
</div>
<div class='post_comment'>
    <a style='color:#9b6bb4 ; text-decoration:none ; position:relative ; top:-5px'>Post Comment:</a>
<input type='text' name='user_comment' class='user_comment'>
<button type='button' class='comment_button' name='sumbit_comment'>Comment</button>
</div>
</div>
</div>
</div>
<script>
//hide comments
$('.comment_wrapper').hide();
//show comments
$(document).ready(function() {
$('.show_comment').click(function() {
$('.comment_wrapper').show(500);
});
});
//hide when 'close' is clicked
$(document).ready(function() {
$('.close_comment').click(function() {
$('.comment_wrapper').hide(500);
});
});
</script>
</body>
</html>
And here is the liked_button.php:
<?php
error_reporting(E_ALL); ini_set('display_errors', 1); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
session_start();
$liked_img_loc = "";//prevent undefined index error
$liked_by = $_SESSION['id'];
$liked_unliked = '1';
$date = date('Y-m-d H:i:s');
$conn = mysqli_connect("localhost","root","") or die ("No SQLI");
mysqli_select_db($conn, "sample") or die ("No DB");
$likes_query = mysqli_query($conn, "SELECT * FROM `likes` WHERE `liked_img_loc` = '$liked_by'");
while($row = mysqli_fetch_assoc($likes_query)) {
$liked_unliked = $row['liked_unliked'];
}
if($row['liked_unliked'] == 1) {//user has already liked
echo "<script type='text/javascript'>alert('Sorry, but you can not like an image twice!');</script>";
} else {//user hasn't already liked the image
$sqli = "INSERT INTO `likes` (liked_img_loc, liked_by, liked_unliked, date) VALUES ('$liked_img_loc','$liked_by','$liked_unliked','$date')";
mysqli_query($conn, $sqli) or die ("No query");
header('location:index.php');
mysqli_close($conn);
}