My code is very messy, but I am trying to make a forum on my website.
<?php
$conn = mysqli_connect("localhost", "root", "");
if($conn->connect_error){
die("Connection Failed");
}
mysqli_select_db($conn, 'forum');
$get= "select * from forum";
$runq = mysqli_query($conn, $get);
while($fetch_value=mysqli_fetch_array($runq)){
$get_usr_name=$fetch_value['username'];
$get_body = $fetch_value['info'];
}
$result = $conn->query($get);
if(is_null($get_body)){
}
else{
echo "<div id='inputform1'>";
for($row = 1; $row < $result->num_rows; $row++){
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$dbname = "forum";
$connection = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
if(mysqli_connect_errno()){
die("database connection failed: ") .
mysqli_connect_errno() .
" (" . mysqli_connect_errno() . ")";
}
$result1 = mysqli_query($connection, "select info from forum where id='$row';");
$result = mysqli_query($connection, "select username from forum where id='$row';");
echo "<strong class=\"after_username\">by: {$result}</strong><br><br><p id=\"bodyforum\">{$result1}<br><br></p>";
}
echo "</div>";
}
?>
I cannot seem to post the username and password; it keeps saying:
Object of class mysqli_result could not be converted to string
I have tried many different "tactics" but none of them seem to work. Can someone help me?