Chuks Posted August 18, 2017 Share Posted August 18, 2017 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 More sharing options...
davej Posted August 18, 2017 Share Posted August 18, 2017 Your question doesn't make any sense. Can the browser display the page? Link to comment Share on other sites More sharing options...
dsonesuk Posted August 18, 2017 Share Posted August 18, 2017 That suggests it can't find that contact.php page, not that there is a database connection problem. Link to comment Share on other sites More sharing options...
Chuks Posted August 18, 2017 Author Share Posted August 18, 2017 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 More sharing options...
davej Posted August 18, 2017 Share Posted August 18, 2017 Show us the include statement that you use, and are all the php files together in one folder? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 18, 2017 Share Posted August 18, 2017 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 More sharing options...
dsonesuk Posted August 18, 2017 Share Posted August 18, 2017 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now