Hey, I'm trying to write a very simple script that will access a mySQL database and pull out some values from a table. I keep getting a syntax error though.
I've tried troubleshooting the problem, and the error only occurs when I try to use a multiline echo with the 'echo <<<EOM ..... EOM;' statement. The statement works fine in isolation, away from the rest of the script, and the mySQL objects work fine too (without the echo)! When I put them together though, an error is generated. Any advice would be greatly appreciated!
<?php
$si = function_exists('mysqli_connect');
if($si){
echo 'mysqli seems to work!';
}
else{
echo 'mysqli isnt installed!';
}
$conn = new mysqli('localhost', 'root', 'mypassword', 'bl0g');
$query = "SELECT * FROM userid";
$result = $conn->query($query);
echo <<<EOM
<table>
<tr>
<td> <b> userid </b> </td>
<td> username </td>
<td> email </td>
</td>
</table>
EOM;
$result->close();
$conn->close();
?>