php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73141 i am running php-Pear project. and error to providing password in dsn .
Submitted: 2016-09-22 06:14 UTC Modified: 2016-09-22 08:42 UTC
From: waqasrana11 at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: MySQL related
PHP Version: 5.6.26 OS: windows 10
Private report: No CVE-ID: None
 [2016-09-22 06:14 UTC] waqasrana11 at gmail dot com
Description:
------------


require_once 'DB.php';
    


      $dsn = 'mysql://root:@localhost/web_cms';
      $options = array(
          'debug'       => 2,
         'portability' => DB_PORTABILITY_ALL,
     );
    
     $dbh =& DB::connect($dsn, $options);
      if (DB::isError($dbh)) {
          die($dbh->getMessage());
      } 





function connect($dsninfo, $persistent = false)
    {
        $db = new DB();
        if (!($db->assertExtension('mysql'))) {
            return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
        }
        $this->dsn = $dsninfo;
        if ($dsninfo['protocol'] && $dsninfo['protocol'] == 'unix') {
            $dbhost = ':' . $dsninfo['socket'];
        } else {
            $dbhost = $dsninfo['hostspec'] ? $dsninfo['hostspec'] : 'localhost';
            if ($dsninfo['port']) {
                $dbhost .= ':' . $dsninfo['port'];
            }
        }

        $connect_function = $persistent ? 'mysql_pconnect' : 'mysql_connect';

        if ($dbhost && $dsninfo['username'] && isset($dsninfo['password'])) {
            $conn = @$connect_function($dbhost, $dsninfo['username'],

// error in the following line       
                    $dsninfo['password']);

        } elseif ($dbhost && $dsninfo['username']) {
            $conn = @$connect_function($dbhost, $dsninfo['username']);
        } elseif ($dbhost) {
            $conn = @$connect_function($dbhost);
        } else {
            $conn = false;
        }

Test script:
---------------
Fatal error in line 132 of fileC:\xampp\htdocs\cms-includes\pear\DB\mysql.php
- mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead

this lin # 132 

$dsninfo['password']);


so my db credentials are  db --> 'web_cms'
username-> 'root'
password --> ' ' 
hots --> localhost


so how can i provide blank or no password in dsn  = mysql//:user:pass@host/db


Expected result:
----------------
just remove this error and should display result 


Patches

php-pear-mysqlDb (last revision 2016-09-22 06:17 UTC by waqasrana11 at gmail dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-09-22 08:42 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2016-09-22 08:42 UTC] cmb@php.net
This doesn't appear to be a general PHP issue, but rather a PEAR/DB
specific one, so please report this at <http://pear.php.net/bugs/>.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC