|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-06-11 21:52 UTC] mbeccati@php.net
-Status: Open
+Status: Verified
-Assigned To:
+Assigned To: mbeccati
[2015-06-11 22:28 UTC] mbeccati@php.net
[2015-06-11 22:28 UTC] mbeccati@php.net
-Status: Verified
+Status: Closed
[2015-06-11 22:28 UTC] mbeccati@php.net
[2015-06-12 00:09 UTC] mbeccati@php.net
[2015-06-23 18:04 UTC] ab@php.net
[2015-06-23 18:04 UTC] ab@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 12:00:02 2025 UTC |
Description: ------------ If a PostgreSQL user's password contains a leading single quote (apostrophe) PDO-pgsql is unable to connect to the database as the user. The script fails with the message: PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[08006] [7] unterminated quoted string in connection info string' Test script: --------------- #!/bin/bash echo "Trailing quote" psql postgres -c "DROP DATABASE IF EXISTS testphp" psql postgres -c "DROP ROLE IF EXISTS testphp" psql postgres -c "CREATE ROLE testphp PASSWORD 'asdf''' LOGIN" psql postgres -c "CREATE DATABASE testphp OWNER testphp" php -r "new PDO(\"pgsql:dbname=testphp\", \"testphp\", \"asdf'\");" echo "Leading quote" psql postgres -c "DROP DATABASE IF EXISTS testphp" psql postgres -c "DROP ROLE IF EXISTS testphp" psql postgres -c "CREATE ROLE testphp PASSWORD '''asdf' LOGIN" psql postgres -c "CREATE DATABASE testphp OWNER testphp" php -r "new PDO(\"pgsql:dbname=testphp\", \"testphp\", \"'asdf\");" Expected result: ---------------- PHP can connect to the database no problem. Output from script: $ bash test.sh Trailing quote DROP DATABASE DROP ROLE CREATE ROLE CREATE DATABASE Leading quote DROP DATABASE DROP ROLE CREATE ROLE CREATE DATABASE Actual result: -------------- $ bash test.sh Trailing quote DROP DATABASE DROP ROLE CREATE ROLE CREATE DATABASE Leading quote DROP DATABASE DROP ROLE CREATE ROLE CREATE DATABASE PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[08006] [7] unterminated quoted string in connection info string' in Command line code:1 Stack trace: #0 Command line code(1): PDO->__construct('pgsql:dbname=te...', 'testphp', ''asdf') #1 {main} thrown in Command line code on line 1