Im trying to have posts from a user show on their profile, the current query I'm using worked fine for showing posts by everyone but when I try to edit it to only show posts by the users profile I am on it outputs these errors:
Notice: Undefined index: Tezma in C:\xampppp\htdocs\socialnetwork\profile_page.php on line 62
Notice: Trying to get property of non-object in C:\xampppp\htdocs\socialnetwork\profile_page.php on line 70
This is all the code that I have so far:
<?php
$conn = new mysqli("localhost", "root", "", "login");
if($conn->connect_error) {
die("Connection Failed: " . $conn->connect_error);
}
$username = $_GET[$data->username]; <-- Line 62
$sql = "SELECT *
FROM posts
WHERE post_user_name = $username
ORDER BY post_date DESC";
$result = $conn->query($sql);
if($result->num_rows > 0) { <-- Line 70
while($row = $result->fetch_assoc()){
echo "<div class='well well-sm'>";
echo "<img style='float:left;margin-right:6px;box-shadow:0px 0px 1px #888;' src='user_pictures/default.jpg' width='7%'>";
echo "<span class='bold'><a href='profile.php?user=".$row['post_user_name']."'>".$row['post_user_name']."</a></span><br>";
echo "<span>".$row['post_date']."</span>";
echo "<hr style='margin-top:2px;margin-bottom:2px;'>";
echo "<p style='margin-bottom:0px;'>".$row['post_content']."</p>";
echo "</div>";
}
} else {
echo "<div class='well well-sm'>";
echo "0 Results";
echo "</div>";
}
$conn->close();
?>