Skip to Content
CentOS System Administration Essentials
book

CentOS System Administration Essentials

by Andrew Mallett
November 2014
Beginner
174 pages
3h 50m
English
Packt Publishing
Content preview from CentOS System Administration Essentials

Create dynamic web content

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

CentOS 8 Essentials

CentOS 8 Essentials

Neil Smyth
Mastering CentOS 7 Linux Server

Mastering CentOS 7 Linux Server

Mohamed Alibi, BHASKARJYOTI ROY

Publisher Resources

ISBN: 9781783985920