|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-11-07 14:17 UTC] cmb@php.net
-Status: Open
+Status: Duplicate
[2016-11-07 14:17 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 08:00:01 2025 UTC |
Description: ------------ When the passowrd is string("") and set ATTR_PERSISTENT is true, the PDO __construct where Fatal Error (You keep press the F5 in the browser , U will see the error some times) If password is not empty or is null , it's ok. $dsn = 'mysql:dbname=test;host=localhost;port=3306'; $user = 'root'; $password = "";//will wrong //$password = null; //will ok try { $dbh = new PDO($dsn, $user, $password, array( \PDO::ATTR_PERSISTENT => true ) ); } catch (PDOException $e) { echo 'Connection failed: ' . $e->getMessage(); } Test script: --------------- <?php /* Connect to an ODBC database using driver invocation */ $dsn = 'mysql:dbname=test;host=localhost;port=3306'; $user = 'root'; $password = ""; $dbh = new PDO($dsn, $user, $password, array( \PDO::ATTR_PERSISTENT => true ) ); print_r($dbh);