I'm trying to query the DB with mysqli and then fetch the result, but it's throwing an Object of class could not be converted to a string error.
Here's what I am trying to accomplish:
<?php
include ('conn.php');
$query= "select value from the_table where item = 'url'";
$result = mysqli_query($conn, $query);
?>
And then I am trying to populate a link with the $result
:
<a href="<?php echo $result; ?>">This is the Link to the URL</a>
I saw this post: PHP and MySQL error: Object of class mysqli_result could not be converted to string
So, I tried to format the echo with echo $result->fetch_object()->url;
, but that didn't work.
I'm not sure if I have to fetch the result and then throw it into a look with a mysqli_fetch_array()
and if so, how do I get it to populate that the value outside of the loop?