November 2014
Beginner
174 pages
3h 50m
English
To demonstrate how easily we can create dynamic web pages that will connect to the database using PHP from the Nginx server, we will create a new PHP page in /var/www/html. So fire up your favorite editor, and we will create the page within the document root, /var/www/html/db.php:
<h2>Databases</h2>
<?php
$dbh=mysqli_connect("localhost","root","Password1");
$result=mysqli_query($dbh, "SHOW DATABASES");
while ($row = mysqli_fetch_assoc($result)) {
echo $row['Database'] . "<BR>";
}
?>The code again is kept as simple as possible, and ideally we would include the connection credentials stored within another file that was not accessible to the web server, allowing access only from the PHP process; however, keeping the code ...