If I load my very simple web page it shows as blank with the PHP at the top

But if I remove the PHP my website loads the few headers I’ve created

<?php $servername = “localhost”; $username = “user”; $password = “password12345”; $dbname = “test”;

// Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); }

// sql to create table $sql = “CREATE TABLE MyGuests ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, firstname VARCHAR(30) NOT NULL, lastname VARCHAR(30) NOT NULL, email VARCHAR(50), reg_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP )”;

if ($conn->query($sql) === TRUE) { echo “Table MyGuests created successfully”; } else { echo "Error creating table: " . $conn->error; }

$conn->close(); ?>

  • loathsome dongeaterA
    link
    fedilink
    arrow-up
    2
    ·
    4 years ago

    If you use code blocks it is easier to read.

    <?php $servername = “localhost”; $username = “user”; $password = “password12345”; $dbname = “test”;
    
    // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); }
    
    // sql to create table $sql = “CREATE TABLE MyGuests ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, firstname VARCHAR(30) NOT NULL, lastname VARCHAR(30) NOT NULL, email VARCHAR(50), reg_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP )”;
    
    if ($conn->query($sql) === TRUE) { echo “Table MyGuests created successfully”; } else { echo "Error creating table: " . $conn->error; }
    
    $conn->close(); ?>
    
  • XiangMaiOP
    link
    fedilink
    arrow-up
    2
    ·
    4 years ago

    I managed to fix this btw

    turns out I didn’t have a bunch of dependencies installed