Error messages takes the user out of page

Hi everyone,
Here is a simple PHP code aimes to connect into a MySql server.
I’m trying to format error messages in a way my page will continue working despite errors that occure.


<?php
$con=mysqli_connect("localhost","root","root4qpines","tivonidb");
if (mysqli_connect_errno($con))
  {
       echo
       '<p class="SQLerror">';
            echo "Failed to connect to MySQL: " . mysqli_connect_error();
            echo
        '</p>';
  }
else
  {
       echo
       '<p class="SQLerror">';
         echo "Success connecting to MySQL! " ;
         echo
       '</p>';
  }
?>

Here’s the css code:


p.SQLerror
	{
		width:447px;
		height:363px;
		background-color: #fd0303;
	}

In return I get error messages that take me out of my page and is inconsistent with the css as shown in the screenshot attached

Have you tried running it in different browsers?

Have you run simple scripts that don’t try to connect to a database?

<?php
echo 'Hello World';
?>