Bladescope Posted March 23, 2008 Share Posted March 23, 2008 Right, starting off, hey and good evening for me. Sorry for what seems like a demanding first post, but any help on this would be greatly appreciated. I'm running php 5.2 on a home server (appserv) and i've been looking into starting to use Php Data Objects with MySQL. Now, when i've tried testing it (using a basic try/connect script) it's generated the error that the PDO class doesn't exist, so I tried the script on my webspace and it worked perfectly, so from what I gathered, it must be something to do with my server's php files. So, opened up my php.ini, and found that the 3 files weren't enabled (and the extension path wasn't set). So, in php.ini, the file now has these lines in it: extension_dir = "./ext" extension=php_mysql.dll extension=php_pdo.dll extension=php_pdo_mysql.dll running php.exe from there, generated no errors about missing files, so i've assumed that it has managed to find the files, or that it just hasn't checked for them, but when I came back to run the same script, it generated the same error which is that the class PDO is non-existant. I've tried restarting my computer and nothing has changed, so i'm asking for a little bit of help as to what else I may need to do to enable PDO for my home server. Here's the code I use: <?php try { $dbh = new PDO('mysql:host=localhost;dbname=test', 'root', 'mypasswordgoeshere'); foreach ($dbh->query('SELECT * from FOO') as $row) { print_r($row); } $dbh = null; } catch (PDOException $e) { print "Error!: " . $e->getMessage() . "<br/>"; die(); } ?> Generates Fatal error: Class 'PDO' not found in C:\AppServ\www\pdo.php on line 3 The extensions are located at: C:\Appserv\php5\ext The php.ini file is located at: C:\Appserv\php5\php.ini Any help at all would be great, and i'll provide more info if you need it. Thanks in advance, Sean. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted March 23, 2008 Share Posted March 23, 2008 Always set the extension_dir with an absolute path: extension_dir = "C:/Appserv/php5/ext" also in order for php to display errors if it is having issues loading extensions during startup you'll need to enable the display_startup_error setting in the php.ini too. Save the php.ini and restart Appserv Quote Link to comment Share on other sites More sharing options...
Bladescope Posted March 23, 2008 Author Share Posted March 23, 2008 Saved and restarted my computer, same error. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted March 23, 2008 Share Posted March 23, 2008 Run phpinfo() and post what the Configuration File (php.ini) Path and Loaded Configuration File lines are set to. One of those two lines should point to the php.ini you are editing (C:\Appserv\php5\php.ini) Quote Link to comment Share on other sites More sharing options...
Bladescope Posted March 23, 2008 Author Share Posted March 23, 2008 Oh darn. I should've thought as much. Let me explain: PHP Version 5.2.3 System Windows NT SEAN 5.1 build 2600 Build Date May 31 2007 09:36:39 Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--with-gd=shared" Server API Apache 2.0 Handler Virtual Directory Support enabled Configuration File (php.ini) Path C:\WINDOWS Loaded Configuration File C:\WINDOWS\php.ini PHP API 20041225 PHP Extension 20060613 Zend Extension 220060519 Debug Build no Thread Safety enabled Zend Memory Manager enabled IPv6 Support enabled Registered PHP Streams php, file, data, http, ftp, compress.zlib Registered Stream Socket Transports tcp, udp Registered Stream Filters convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, zlib.* the question remains, do I need to put my php.ini file in the WINDOWS directory, or is there some way to change the path. (Thanks for the help so far, helped a lot) Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted March 23, 2008 Share Posted March 23, 2008 PHP is currently reading a php.ini in C:\WINDOWS\ if you are editing the php.ini in C:\Appserv\php5 either delete the current php.ini in C:\WINDOWS or overwrite it with the one in C:\Appserv\php5 Make sure your restart Appserv after moving the php.ini Quote Link to comment Share on other sites More sharing options...
Bladescope Posted March 23, 2008 Author Share Posted March 23, 2008 Thank you so much, that has fixed it! I'll be sure to stick around and help those that need it too. Thanks again! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.