Jump to content
Chuks

Problem Connecting to MySQL

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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Show us the include statement that you use, and are all the php files together in one folder?

Share this post


Link to post
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.

Share this post


Link to post
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";    
?>

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...