Reputation: 1
I am trying to make a basic forum, and I am having trouble printing just one row in SQL. Here is my PHP:
<?php
ob_start();
$host = "localhost";
$user = "root";
$pass = "MYPASSWORD";
$db = "MYDB";
$conn = mysqli_connect($host, $user, $pass, $db) or die("cannot connect to database.");
$sql = "SELECT * FROM forum WHERE fid = '{$fid}' JOIN user ON forum.creator=user.id;";
$result = mysqli_query($conn, $sql);
if ($result == true) {
while ($row = mysqli_fetch_assoc($result)) {
print "<h1>{$title}</h1>";
}
}
else {
print "failed to reach post.";
}
ob_flush();
?>
To help out, I believe everything works except for $sql
. I have enabled ini_set('display_errors',1);
but I am getting no error messages (excpet for my own that I made for the else statement).
Upvotes: 0
Views: 65
Reputation: 2200
Try this query
SELECT * FROM forum JOIN user ON forum.creator=user.id WHERE fid = '{$fid}' ;
Upvotes: 1