php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #67056 '...;dbname =xyz;...' unexpected behavior
Submitted: 2014-04-10 13:50 UTC Modified: 2014-12-30 10:42 UTC
From: skvsn at ngs dot ru Assigned:
Status: No Feedback Package: PDO related
PHP Version: Irrelevant OS: Ubuntu 13.10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: skvsn at ngs dot ru
New email:
PHP Version: OS:

 

 [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)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-04-10 13:52 UTC] skvsn at ngs dot ru
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
 [2014-04-10 17:13 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2014-04-10 17:13 UTC] requinix@php.net
And the exact same code without the space there works?
 [2014-04-17 07:50 UTC] skvsn at ngs dot ru
Yep, that's the point.
The exact same code without the space there works fine.
 [2014-12-30 10:42 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 20:01:29 2024 UTC