Mysql
 sql >> Database >  >> RDS >> Mysql

Accesso negato per l'utente ''@'localhost' (tramite password:NO)

Questo perché crei una connessione usando mysqli_ e poi usa mysql_ per cercare di recuperare il tuo risultato. Sono API diverse.

<?php

/* You should enable error reporting for mysqli before attempting to make a connection */
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

$mysqli = mysqli_connect('localhost', 'my_user', 'my_password', 'my_db');

/* Set the desired charset after establishing a connection */
mysqli_set_charset($mysqli, 'utf8mb4');

printf("Success... %s\n", mysqli_get_host_info($mysqli));

Esempio tratto dal manuale PHP