Skip to content

@eMerzh /pdo_test.php
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Pg PDO test
<?php
/** createuser -d -R -S -P test
* => set password to "a b c"
*/
$dsn = "pgsql:dbname=test;host=localhost";
$user = "test";
$psw = "a b c";
try{
$db = new PDO($dsn,$user,$psw);
echo "Oh gosh!\n";
}catch(PDOException $e){
echo "Error :" . $e."\n";
}
$e_user = addslashes($user);
$e_password = addslashes($psw);
$psw = $user = null;
$dsn .= ";user='$e_user';password='$e_password'";
try{
$db = new PDO($dsn,$user,$psw);
echo "it's working!\n";
}catch(PDOException $e){
echo "Error :" . $e."\n";
}
/***
Error :exception 'PDOException' with message 'SQLSTATE[08006] [7] missing "=" after "b" in connection info string' in /var/www/owncloud/pg_test.php:11
Stack trace:
#0 /var/www/owncloud/pg_test.php(11): PDO->__construct('pgsql:dbname=te...', 'test', 'a b c')
#1 {main}
it's working!
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.