here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta
The Data Source Name Provided Is Invalid Verify That It Is A Valid Class Name
Discuss the workings and policies of this site About Us Learn
Invalid Data Source Name Laravel
more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us medoo invalid data source name Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like http://stackoverflow.com/questions/19740829/uncaught-exception-pdoexception-message-invalid-data-source-name you, helping each other. Join them; it only takes a minute: Sign up “invalid data source name” with PDO MySQL up vote 0 down vote favorite It was always working for me but this time it's not. conect.ini conn = "mysql:host=localhost; dbname=%dbname%" user = "root" pass = "%passwd%" conn1 = "mysql:host=%myRealHostAddr%; dbname=%dbname%" user1 = "%user%" pass1 = http://stackoverflow.com/questions/16980635/invalid-data-source-name-with-pdo-mysql "%passwd%" pdo class prepeared { const LOG = "lock/loginsStat.log"; private $_db; private $dbc; function __construct(){ $this->dbc = parse_ini_file($_SERVER["DOCUMENT_ROOT"]."/hours/lock/conect.ini"); try{ $this->_db = new PDO($this->dbc["conn"], $this->dbc["user"], $this->dbc["pass"]); }catch(PDOException $e){ echo $e->getMessage(); } } etc.... Vars %var% are real values just changed them for this post. Vars with 1 are working at the hosting just fine (without 1, it was added only for a local testing). When I take it to a local machine for some testing I'm adding this 1 to disable them and making a new vars for a local settings. The error that I see now it's invalid data source name Any ideas why? I know that this configuration was working just fine when I used it couple weeks ago so I suspect there is no errors here. Probably I'm wrong... php mysql pdo ini share|improve this question asked Jun 7 '13 at 9:25 Kirill Ivanov 2716 add a comment| 1 Answer 1 active oldest votes up vote 0 down vote accepted Get rid of catch(PDOException $e){ e
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss http://stackoverflow.com/questions/15895959/database-connection-could-not-be-established-invalid-data-source-name-only-wit the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping data source each other. Join them; it only takes a minute: Sign up Database connection could not be established; Invalid data source name (Only with PDO) up vote 1 down vote favorite i'm trying to reach my new PGSQL database with PHP. The problem is that i recieve the error given in the title. When i try to connect direct. data source name It works, when i try to connect by PDO, it gives this error. What i checked: PHP.ini. The required extensions are uncommented (both php_pgsql.dll and php_pdo_pgsql.dll) Made sure these two files are really in the PHP folder. Made sure the database,host,user,pass and port are correct by using simple script (shown belown) This is my config file for setting up the databases (i'm using 6 databases correctly. So i know the fault is not in that file) "Aeges":{ "pdo_driver":"odbc", "user":"XXXX", "password":"XXXX", "database":"test", "host":"localhost", "port":1233 }, "Postgre":{ "pdo_driver":"pgsql", "user":"XXXX", "password":"XXXX", "database":"ASN", "host":"localhost", "port":5432 } etc.. This is my function to retrieve the information. I cleaned it up a bit to make it clear public static function findAvailableASN() { $Postgre = db\Factory::getInstance()->create('Postgre'); $stmt = $Postgre->prepare("select * from asnregel.asnregel"); if ($stmt->execute()) { return $stmt->fetchAll(\PDO::FETCH_ASSOC); } /* $connect = pg_connect("host=localhost port=5432 dbname=ASN user=XXXX password=XXXX"); if(!$connect) { die("Error in connection: ".pg_last_error()); } $sql = "select * from asnregel.asnregel"; $result = pg_query($connect,$sql); if(!$result) { die("Error in sql query: ".pg_last_error()); } while($row = pg_fetch_array($result)) { echo $row[0].'
'; echo $row[1].'
'; e