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']}; ?> Link to comment https://forums.phpfreaks.com/topic/214744-echo-data-of-an-sql-query-nothing-echoing/ 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. Link to comment https://forums.phpfreaks.com/topic/214744-echo-data-of-an-sql-query-nothing-echoing/#findComment-1117263 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 Link to comment https://forums.phpfreaks.com/topic/214744-echo-data-of-an-sql-query-nothing-echoing/#findComment-1117330 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.