0

I am working on the tutorial from ProgrammingProfessor on YT. 04 - Connect to a MySQL database in PHP (https://www.youtube.com/watch?v=uXPnY9hQeL0&list=PLhPyEFL5u-i0zEaDF0IPLYvm8zOKnz70r&index=4)

Now I have the code like in the video:

<html>

<head>

</head>
<body>
<h1>hello</h1>
    <?php

        $servername = "localhost";
        $username = "username";
        $password = "password";
        $database_in_use="test";

        // Create connection
        $mysqli = new mysqli($servername, $username, $password, $database_in_use);

        // Check connection
        if (mysqli->connect_errno) {
          echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
        }
        echo $mysqli ->host_info. "\n";

    ?>

</body>

</html>

But I have the Problem that I only get the header displayed at localhost and nothing else.

If I check the sorucecode online I found that it stopped at the header (see picture) enter image description here

It is not working yet

ProgJonny
  • 9
  • 2
  • It looks like you are using some really bad tutorial. I highly encourage you to find something better. If you are only starting to learn PHP then you should learn PDO instead of mysqli. PDO is much easier and more suitable for beginners. Start here https://phpdelusions.net/pdo & https://websitebeaver.com/php-pdo-prepared-statements-to-prevent-sql-injection. Here are some good video tutorials https://youtu.be/2eebptXfEvw & https://www.youtube.com/watch?v=sVbEyFZKgqk&list=PLr3d3QYzkw2xabQRUpcZ_IBk9W50M9pe- – Dharman Sep 28 '22 at 21:13
  • You have an error that is easily highlighted by a proper IDE. I use VS Code and it highlights one line of code in red. Please consider using a better learning resource and a proper IDE that will tell you about your typos. – Dharman Sep 28 '22 at 21:16

0 Answers0