buzzkip Posted September 29, 2010 Share Posted September 29, 2010 Hi All, I'm trying to echo the response from an SLA query, the query works and returns the data when I test it on an SQL application.. but when I run it on my webpage it won't echo the result. Please help? <?php $mysqli = mysqli_connect("removed", "removed", "removed", "removed"); $sql = "SELECT posts.message FROM posts INNER JOIN threads ON posts.pid=threads.firstpost WHERE threads.firstpost='1'"; $result = mysqli_query($mysqli, $sql); echo {$result['message']}; ?> Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted September 29, 2010 Share Posted September 29, 2010 $result holds a resource, not a value. You need to do something with the result to get the values you're looking for, mysqli_fetch_assoc(), mysqli_result(), etc. Quote Link to comment Share on other sites More sharing options...
buzzkip Posted September 29, 2010 Author Share Posted September 29, 2010 When I use: <?php $mysqli = mysqli_connect("removed", "removed", "removed", "removed"); $query = "SELECT posts.message FROM posts INNER JOIN threads ON posts.pid=threads.firstpost WHERE threads.firstpost='1' "; $result = mysqli_query($mysqli,$query); while ($row = mysqli_fetch_assoc($result)) { echo $row['message'] . "<br/>"; } ?> I get error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /removedURL/forumdisplay.php(1123) : eval()'d code on line 39 When I take away the set of line 39 and use this: <?php $mysqli = mysqli_connect("removed", "removed", "removed", "removed"); $query = "SELECT posts.message FROM posts INNER JOIN threads ON posts.pid=threads.firstpost WHERE threads.firstpost='1' "; $result = mysqli_query($mysqli,$query); ?> I get this error: Error Type: Catchable Fatal Error (4096) Error Message: Object of class mysqli_result could not be converted to string Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.