Just installed MAMP and am learning about php and connecting to my databases. I seem to be able to connect to mysql but can't connect or see any databases in phpMyAdmin.
Here's my php code:
<?php
$user = 'root';
$password = 'root';
$db = 'test';
$host = 'localhost';
$link = mysqli_connect($host, $user, $password);
//newly editied
if ($link->connect_error) {
die('Connect Error (' . $mysqli->connect_errno . ') '
. $mysqli->connect_error);
}
$db_selected = mysqli_select_db($db, $link);
if (!$db_selected) {
echo "did not connect";
}
?>
When I run it, I'll get the words "good", so I know I'm connecting, followed by "did not connect", so it's not connecting to my database.
I've also tried adding this code and nothing gets echoed at all even though I have several databases created.
$res = mysqli_query("SHOW DATABASES");
while ($row = mysqli_fetch_assoc($res)) {
echo $row['Database'] . "\n";
}
Any help is appreciated!