I tried connecting my PHP file to MySQli database but when i ran the code it displays
But when i logon to phpmyadmin it works fine no errors i can login to my account with no problems
Connection Code:
<?php
$con = mysqli_connect('localhost','sotomango', '1234', 'mysql');
if(!$con) {
echo 'noooo';
}
?>
I double checked the database usernames, passwords, and privileges. Everything seems in place and correct, but the php file wont allow me to connect to the database.
2
Answers
For The People Wondering
I solved this by just adding a port to the host name like
localhost:3308
@Dharman had a nice post but I couldnt find it.
Try this for debug :
mysqli_connect
if its a new instalation or new upgrade, You need to include your port into connection, mariadb comes as default port so, when you try to connect mysql its redirecting to mariadb.
you need to include your correct port into connection it might be 3306, 3307 or 3308, and use ip instead of localhost.
your final codes should look like this :