|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-04-10 13:50 UTC] skvsn at ngs dot ru
Description:
------------
PDO constructor would fail to understand you give database name, provided you pass $dsn like '...;dbname =xyz;...', i.e. in case there's a whitespace in between "dbname" and "=".
Test script:
---------------
$pdo = new \PDO("mysql:host=localhost;port=3306;dbname =$dbname;charset=utf8", $username, $password);
$sth = $pdo->query("select * from $tablename");
var_dump($a->errorInfo());
Actual result:
--------------
// var_dump dsn:
string 'mysql:host=localhost;port=3306;dbname =mydatabase;charset=utf8' (length=66)
// var_dump username
string 'theuser' (length=14)
// var_dump password
string 'thepassword' (length=6)
// var_dump pdo->errorInfo()
array (size=3)
0 => string '3D000' (length=5)
1 => int 1046
2 => string 'No database selected' (length=20)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 18:00:01 2025 UTC |
PHP 5.5.3-1ubuntu2.2 (cli) (built: Feb 28 2014 20:03:35) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies with Xdebug v2.2.4, Copyright (c) 2002-2014, by Derick Rethans