Skip to main content
GameDev.net gamedev.net
🔒 Locked

[web] PHP PDO cannot find driver

Started by stlfbr1 Mar 21, 2009 at 3:24 PM 6 replies 4.1k views
Original Post
stlfbr1
stlfbr1
So Im trying to create a web project with php and I need to connect to a MySQL db. I get the error cannot find driver when i try to create the PDO object. I am also using apache2.2 and php5. i have the php5ts.dll in windows/system32. I have uncommented out the extension=php_mysql.dll, extension=php_pdo.dll, extension=php_pdo_mysql.dll and the extension_dir = "C:\php\ext\" in php.ini. In the apache config i have: LoadModule php5_module "C:/php/php5apache2_2.dll" AddType application/x-httpd-php .php PHPIniDir "C:/php" DirectoryIndex index.php Just not sure what the problem could be? I have all the dll's where they should be and everything pointing where it should be, but still says could not find driver. Any help would be appreciated!!! Thanks!
let_bound
let_bound
Have you restarted Apache after making the modifications?
stlfbr1
stlfbr1
Yes, several times and restarted the computer as well.
let_bound
let_bound
I don't know much about Apache et PHP, and even less about Windows, but could it be a permission problem? The Apache process needs to be able to load the libraries. You're also mixing forward- and backslashes, so I'd make sure that backslashes are authorized at all in the Apache configuration files.

How are you creating the PDO object?
stlfbr1
stlfbr1
Yes I was thinking it may be a 'slash' issue. Apache is able to find the php stuff that it needs and I'm able to do all different stuff (i mostly just used session vars as a test for the php working). The only issue is with the PDO object/connection.

So I was thinking it must lie with the extension_dir value. Should this say "C:\php\ext\" or "C:/php/ext/"? Also is there a way to output where it is looking for these drivers? That would be a huge help being able to pinpoint the issue.

Here is how I create my PDO object:


$url = $ini['url'];
$user = $ini['user'];
$password = $ini['password'];
$cx = new PDO($url, $user, $password);


And at hitting the last line the error could not find driver is produced.

(On another note, i have it working on another computer, same versions of everything, even copied the php.ini file and the apache config file exactly and still unable to get working on my home computer. The problem with the other computer is I get a VERY weird error when running a query and it is more desirable to be able to work on it at home.)

Thanks for the input
Mastadon
Mastadon
Are you positive that the pdo_mysql extensions were installed when you installed PHP? I ran into a similar problem, and it turned out I didn't install the proper extensions/libraries when I first installed PHP.
stlfbr1
stlfbr1
I did the installation manually. I had the zip, unzipped it to C:\php, then copied php5ts.dll to windows/system32. Then made php.ini changes and apache changes.

How would I go about installing pdo_mysql extensions? Do i need to do anything other than uncomment the extension=... and set the extension_dir?
stlfbr1
stlfbr1
So I got the solution for this.

I had to put the php.ini file in the Apache2.2\bin\ folder. Works fine now, thanks! Also the memory error was solved by putting libmysql.dll in windows\system32 folder.

Thanks for the help everyone!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.