Jump to content

Problem Connecting to MySQL


Chuks

Recommended Posts

Please I  have not been able to connect to MySQL.  After opening a connect and checking the connection, I received the message: " 404 Not Found. The requested URL /contact.php was not found on this server.

How do I go about this, I need help please.

Thanks.

Link to comment
Share on other sites

 

Here is the contact.php  file:

<?php

$servername = "localhost";
$username = "root"
$password = "";

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

// Check connection
if($conn ->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";    
?>

 

Thanks

Link to comment
Share on other sites

If the server sends a 404 response that means it cannot find the file you are looking for.  The contact.php file is not on the web server where you're looking for it, it doesn't have anything to do with the code in the file unless the server is configured to respond with a 404 for other errors for some reason.

Link to comment
Share on other sites

This should not be bring up 404 error, but you have missed a semi colon that will cause a php server error

<?php

$servername = "localhost";
$username = "root";
$password = "";

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

// Check connection
if($conn ->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";    
?>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...