Visualizzazione dei risultati da 1 a 5 su 5
  1. #1

    PDO errore PDOException' with message 'SQLSTATE[HY000] [1045]

    Sto tentando tramite PDO di conettermi al Mysql
    Codice PHP:
    $hostIn 'localhost';
    $dbIn 'database';
    $userIn 'root';
    $passwordIn ' ';

        try {
            
    $MySQLDataBaseLink = new PDO(
                
    "mysql:host=" $hostIn ";dbname=" $dbIn$userIn
                
    $passwordIn);
            
    $MySQLDataBaseLink->setAttribute(PDO::ATTR_ERRMODE,
                
    PDO::ERRMODE_EXCEPTION);
            return 
    $MySQLDataBaseLink;
            } catch(
    PDOException $e) {
                echo 
    '<h3>
    Catch Connect Error--->>> ' 
                    
    $e->getMessage() . '
    </h3>'
    ;
              return 
    false;
            } 
    //End Try Catch
     // End connectToMySQL() function 
    ma mi da questo risultato Catch Connect Error--->>> SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)

    Per il tutto uso Xampp 1.8.1 (Apache 2.4.3, MySQL 5.5.27, PHP 5.4.7)


  2. #2
    Utente di HTML.it L'avatar di neroux
    Registrato dal
    Aug 2009
    Messaggi
    1,973

    Re: PDO errore PDOException' with message 'SQLSTATE[HY000] [1045]

    Originariamente inviato da lucavalentino
    ma mi da questo risultato Catch Connect Error--->>> SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)

    www.sitemeer.com » Quando un sito pare irraggiungibile

    Se ti piace ci puoi trovare anche su Facebook

  3. #3

    Re: PDO errore PDOException' with message 'SQLSTATE[HY000] [1045]

    Sto tentando tramite PDO di conettermi al Mysql
    Codice PHP:
    $hostIn 'localhost';
    $dbIn 'database';
    $userIn 'root';
    $passwordIn ' ';

        try {
            
    $MySQLDataBaseLink = new PDO(
                
    "mysql:host=" $hostIn ";dbname=" $dbIn$userIn
                
    $passwordIn);
            
    $MySQLDataBaseLink->setAttribute(PDO::ATTR_ERRMODE,
                
    PDO::ERRMODE_EXCEPTION);
            return 
    $MySQLDataBaseLink;
            } catch(
    PDOException $e) {
                echo 
    '<h3>
    Catch Connect Error--->>> ' 
                    
    $e->getMessage() . '
    </h3>'
    ;
              return 
    false;
            } 
    //End Try Catch
     // End connectToMySQL() function 
    Se metto la password senza spazio mi compare solo No database selected
    Con Xampp do defaul la password è vuota. Forse è il problema?

  4. #4
    Utente di HTML.it L'avatar di luca200
    Registrato dal
    Apr 2002
    Messaggi
    4,120

    Re: Re: PDO errore PDOException' with message 'SQLSTATE[HY000] [1045]

    Originariamente inviato da lucavalentino
    Se metto la password senza spazio mi compare solo No database selected
    Il che significa che il login è andato bene....

  5. #5
    Allora per fare una semplice stampa del DB tramite PDO.
    Voglio passare dalle funzioni mysql_ .... a PDO.
    Grazie

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.