PhpMyAdmin is not a database, and mysql does not connect via HTTP , mysql itself is already a protocol of its own TCP.
Difference of Mysql and Phpmyadmin
read this:
Do not use the old API
The functions that begin with mysql_
in the prefix are from the old API , read this:
How to use the MySqli API to connect to the Mysql database
The variable $host
should only contain the HOST of your mysql server, that has nothing to do with Apache and nothing to do with HTTP:
<?php
$host = 'localhost';
$usuario = 'root';
$senha = 'minhasenha';
$banco = 'meubanco';
$link = mysqli_connect($host, $usuario, $senha, $banco);
if (mysqli_connect_error()) {
printf('Erro de conexão: %s', mysqli_connect_error());
exit;
}
if (!mysqli_set_charset($link, 'utf8')) {
printf('Error ao usar utf8: %s', mysqli_error($link));
exit;
}
if ($result = mysqli_query($link, 'SELECT * FROM nome')) {
/* Pegando os dados */
while ($row = mysqli_fetch_assoc($result)) {
echo $row['nome'];
}
/* libera os resultados */
mysqli_free_result($result);
} else {
/*Trata o erro da query, se ocorrer*/
printf('Erro na query: %s', mysqli_error($link));
exit;
}
/* fecha a conexão */
mysqli_close($link);
Handling query error:
Your query is probably wrong, so you commented:
With mysqli another error occurs, in the case of Mysqli_fetch_array () expects parameter 1 to be mysqli_result, Boolean given - Otávio Guilherme
As the example I've done, there's an if and an else:
if ($result = mysqli_query($link, 'SELECT * FROM nome')) {
... SE OCORRER TUDO NORMAL ...
} else {
... SE TIVER UM ERRO NA QUERY ...
}
UTF-8
If you do not use UTF-8 remove this part:
if (!mysqli_set_charset($link, 'utf8')) {
printf('Error ao usar utf8: %s', mysqli_error($link));
exit;
}