This question already has an answer here:
I was trying to just print the content of my MySQL Database with PHP.
This is how my database looks like:
mysql> show tables;
+-------------------+
| Tables_in_myTable |
+-------------------+
| users |
+-------------------+
1 row in set (0,00 sec)
mysql> select * from users;
+------------+
| name |
+------------+
| Nick |
+------------+
1 row in set (0,00 sec)
My PHP code looks like this:
<?php
echo "HI"; //to see, that the php gets runned at all.
$connection = mysql_connect('localhost', 'root', ''); //The Blank string is the password
mysql_select_db('myTable');
$query = "SELECT * FROM users";
$result = mysql_query($query);
echo "<table>";
while($row = mysql_fetch_array($result)){
echo "<tr><td>" . $row['name'] . "</td></tr>";
}
echo "</table>";
mysql_close();
?>
But on the website, the only output I get is
"HI"
I checked the username, passwd and DB-Names in my PHP.
I'm running an apache2 Server on Ubuntu (Ubuntu Gnome, if that matters) 16.10 and the community version of MySQL
</div>