# Inconsistancy in PDO dsn

- Thread: https://externals.io/message/22994
- Original archive: https://news-web.php.net/php.internals/22994
- Started by Kevin Waterson on 2006-04-27T15:43:07+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #22994 — Kevin Waterson — 2006-04-27T15:43:07+00:00

URL: https://externals.io/message/22994#22994

Not a bug, but inconsistant behavior in PDO when calling
$dsn = new PDO("sqlite: dbname.sdb");

The space after the colon _should_ be encoded but if not it fails and 
needs correctly to read
$dsn = new PDO("sqlite:dbname.sdb");

Pierre pointed to a user note in the manual  http://www.php.net/manual/en/ref.pdo.php

01-Jan-2006 04:09 
Watch out for putting spaces in the DSN
mysql:host=localhost;dbname=test works
mysql: host = localhost; dbname=test works
mysql: host = localhost; dbname = test doesn't work...

Here we see the inconsistancy at work.
perhaps `E_STRICT` would be a better way to handle this perhaps
some other. 

Kind regards
Kevin

-- 
"Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote."

---

## #23000 — Wez Furlong — 2006-04-28T00:19:06+00:00

URL: https://externals.io/message/22994#23000 · In reply to: #22994

The manual doesn't tell you that you can use spaces, so simply don't do it.

--Wez.


> Not a bug, but inconsistant behavior in PDO when calling
> $dsn = new PDO("sqlite: dbname.sdb");
>
> The space after the colon _should_ be encoded but if not it fails and
> needs correctly to read
> $dsn = new PDO("sqlite:dbname.sdb");
>
> Pierre pointed to a user note in the manual  http://www.php.net/manual/en/ref.pdo.php
>
> 01-Jan-2006 04:09
> Watch out for putting spaces in the DSN
> mysql:host=localhost;dbname=test works
> mysql: host = localhost; dbname=test works
> mysql: host = localhost; dbname = test doesn't work...
>
> Here we see the inconsistancy at work.
> perhaps `E_STRICT` would be a better way to handle this perhaps
> some other.
>
> Kind regards
> Kevin
>
> --
> "Democracy is two wolves and a lamb voting on what to have for lunch.
> Liberty is a well-armed lamb contesting the vote."

---

## #23001 — Kevin Waterson — 2006-04-28T01:08:39+00:00

URL: https://externals.io/message/22994#23001 · In reply to: #23000

This one time, at band camp, "Wez Furlong" <kingwez@gmail.com> wrote:

> The manual doesn't tell you that you can use spaces, so simply don't do it.

but in this example we have a space and it works
mysql: host = localhost; dbname=test

Kevin


-- 
"Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote."

---

## #23002 — Wez Furlong — 2006-04-28T01:24:17+00:00

URL: https://externals.io/message/22994#23002 · In reply to: #23001

> This one time, at band camp, "Wez Furlong" <kingwez@gmail.com> wrote:
> > […]
>
> but in this example we have a space and it works
> mysql: host = localhost; dbname=test

The manual doesn't tell you that you can use spaces.
So, *don't do that*.

The behaviour may change; relying on undefined behaviour means that
you can expect your application to break one day, later rather than
sooner.

So, one last time: *don't do that*.

--Wez.
