?
Solved

PDO extension not running from cmd line

Posted on 2006-06-05
3
Medium Priority
?
372 Views
Last Modified: 2013-12-13
I have a complex batch file to sync a very obscure ODBC DB to mysql. in the batch script is this line

C:\wamp\php\php-win.exe C:\wamp\www\aloe\testing\ODBC_comparison\table_index_sync.php

when i created this I am very certain it worked very well now it is giving me a strange error

Fatal error: Class 'PDO' not found in C:\wamp\www\aloe\testing\ODBC_comparison\table_index_sync.php on line 178

the code i have written is


      try {
            $dbh = new PDO($dsn, $user, $pass);
            $count = 1 ;
            foreach ($query_array as $query) {
                  $res = $dbh->exec($query);
                  if ($res !== false) {
                        print "Table ".$count." Alteration Successfull";
                        print "<br> \n";
                  } else {
                        print "Problem with your code idiot around table " .$count;
                        print "<br> \n";
                  }
                  $count++;
            }

      } catch (PDOException $e) {
            die("Error Connection: -  ". $e->getMessage());
      }

with the query strings in the same file

I am using the latest of everything and if this is run thru the browser it works fine
0
Comment
Question by:mrwilde
  • 2
3 Comments
 
LVL 40

Accepted Solution

by:
Richard Quadling earned 2000 total points
ID: 16840485
Create info.php as ...

<?php phpinfo(); ?>

Run it through the browser and look for the php.ini file location and name.

At the command prompt type ...

c:\wamp\php\php -i | find "Configuration File"

Are they the same file?

I use PHP4 and PHP5 on the same machine quite happily.

I use PHP4 as CGI only and this uses C:\windows\php.ini

I use PHP5 as ISAPI (Sambar Server) and this uses c:\windows\php-isapi.ini

I use PHP5 as CLI and this uses c:\windows\php-cli.ini

As of PHP5, each SAPI can have its own php.ini file (I believe - I only use 2, but the php-src code SEEMS to support this).

What are you getting?

For each ini file you have, check that the appropriate extensions are being loaded

ext=php_pdo.dll

and not

;ext=php_pdo.dll

If you are also using other PDO drivers, they MUST be loaded AFTER the main PDO library ...

extension=php_pdo.dll
extension=php_pdo_firebird.dll
extension=php_pdo_mssql.dll
extension=php_pdo_mysql.dll
extension=php_pdo_oci.dll
extension=php_pdo_oci8.dll
extension=php_pdo_odbc.dll
extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll


and NOT

extension=php_pdo_firebird.dll
extension=php_pdo_mssql.dll
extension=php_pdo_mysql.dll
extension=php_pdo_oci.dll
extension=php_pdo_oci8.dll
extension=php_pdo_odbc.dll
extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
extension=php_pdo.dll


NOTE: Only enable the actual ones you need!!
0
 
LVL 1

Author Comment

by:mrwilde
ID: 16847054
Well thats cool. the funny part is actually thought about that last night in my sleep, thinking that it was looking at the wrong php.ini file.
I had installed Zend platform as I use Zend studio and the php is run on a wamp server on our server here ( just finsihed the new linux server for the intranet ) .

Anyway yes you where right on the money.  It was pointing to php-cli.ini witch only had like 4 entries all realted to zend.  I created a new ini for it to look at and no problem, all working great.

Thanks for the help and the speady response
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 16849958
NP.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month15 days, 8 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question