Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> PDO - problem z łączeniem z bazą danych...
Hubi.pl
post
Post #1





Grupa: Zarejestrowani
Postów: 73
Pomógł: 0
Dołączył: 16.10.2004
Skąd: Poznań

Ostrzeżenie: (0%)
-----


Witam,
postanowiłem sprawdzić ten dodatek w php5, a mianowicie PDO.
Na samym poczatku niestety napotkałem na błędy (IMG:http://forum.php.pl/style_emoticons/default/sad.gif)

przy takim kodzie pojawił mi się taki błąd:
  1. <?php
  2. $dbh = new PDO('mysql:dbname=php5;host=localhost', 'root', '');
  3. // let's have exceptions instead of silence.
  4. // other modes: PDO_ERRMODE_SILENT (default - check $stmt->errorCode() and $stmt->errorInfo())
  5. // PDO_ERRMODE_WARNING (php warnings)
  6. $dbh->setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_EXCEPTION);
  7. // one-shot query
  8. $dbh->exec("create table test(name varchar(255) not null primary key, value varchar(255));");
  9. ?> 

Cytat
Fatal error: Uncaught exception 'PDOException' with message '[2017] Can't open named pipe to host: . pipe: MySQL (2)' in F:\cms\php5\test.php:3 Stack trace: #0 F:\cms\php5\test.php(3): PDO->__construct('mysql:dbname=ph...', 'root', '') #1 {main} thrown in F:\cms\php5\test.php on line 3

natomiast przy takim:
  1. <?php
  2. try {
  3. $dbh = new PDO("mysql:php5", "root", "");
  4. print "Connectedn";
  5. } catch (Exception $e) {
  6. echo "Failed: " . $e->getMessage();
  7. }
  8. ?>

błąd był tego typu:
Cytat
Failed: [2017] Can't open named pipe to host: . pipe: MySQL (2)


Hm... co może być źle?
Po tych rodzajach błedów szukałem trochę i zauważyłem, że wiele osób ma podobne problemy.. lecz prawidłowego rozwiązania nie było (IMG:http://forum.php.pl/style_emoticons/default/sad.gif)

Macie jakieś pomysły?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
chmolu
post
Post #2





Grupa: Zarejestrowani
Postów: 179
Pomógł: 0
Dołączył: 8.10.2004

Ostrzeżenie: (0%)
-----


Myślę, że problem raczej nie leży w samym PDO. Bardziej prawdopodobne jest złe ustawienie mySQLa. Napisz, jakiej wersji używasz.

Przeszperałem trochę google i znalazłem coś takiego (może się przyda):
Cytat
Can't open named pipe error
If you use a MySQL Version 3.22 server on NT with the newest MySQL client programs, you will get the following error:

error 2017: can't open named pipe to host: . pipe...
This is because the release version of MySQL uses named pipes on NT by default. You can avoid this error by using the --host=localhost option to the new MySQL clients or create an option file `C:\my.cnf' that contains the following information:

[client]
host = localhost
Starting from 3.23.50, named pipes are enabled only if mysqld-nt or mysqld-max-nt is started with --enable-named-pipe.
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 12.10.2025 - 14:52