PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
ERROR: could not connect: could not find driver

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> PEAR
View previous topic :: View next topic  
Author Message
Jernx



Joined: 29 Aug 2008
Posts: 2

PostPosted: Fri Aug 29, 2008 3:40 pm    Post subject: ERROR: could not connect: could not find driver Reply with quote

I got this error: ERROR: could not connect: could not find driver
It will download a XLS file, but it only contains above error. What can I do about that?
Anyone an idea?
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1235

PostPosted: Fri Aug 29, 2008 4:06 pm    Post subject: Reply with quote

Which package are you using? What are you trying to do?

Please use the appropriate forum category next time.
Back to top
View user's profile Send private message
Jernx



Joined: 29 Aug 2008
Posts: 2

PostPosted: Fri Aug 29, 2008 4:14 pm    Post subject: Reply with quote

Sorry Mark. Will do next time.
I use Spreadsheet Excel.

I will post my code here:

Code:

<?php           
include('PEAR/Spreadsheet/Excel/Writer.php');
            $excel = new Spreadsheet_Excel_Writer('voorregistraties.xls');
           
            $excel->send('voorregistraties.xls');
           
            $sheet =& $excel->addWorksheet('Voorregistraties');
           
            try
            {
                $pdo = new PDO ('mysql:dbname=****;host=****', '****', '****');
            }
            catch (PDOException $e)
            {
                die("ERROR: could not connect: ".$e->getMessage());
            }
           
            $rowCount = 0;
            $sql = "SELECT * FROM voorgeregistreerde";
            if($result = $pdo->query($sql))
            {
                for ($x = 0; $x<$result->columnCount(); $x++)
                {
                    $meta = $result->getColumnMeta($x);
                    $sheet->write($rowCount, $x, $meta['name']);
                }
                $rowCount++;
                while($row = $result->fetch())
                {
                    foreach($row as $key => $value)
                    {
                        $sheet->write($rowCount, $key, $value);
                    }
                    $rowCount++;
                }
            }
            else
            {
                echo "ERROR: Could not execute $sql.".print_r($pdo->errorinfo());
            }
           
            unset($pdo);
?>
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1235

PostPosted: Fri Aug 29, 2008 4:18 pm    Post subject: Reply with quote

Another recommendation: Please use the [code] environment here in the forum next time. It will make your code much more readable.

The problem seems to be that your PHP installation is missing the PDO_MYSQL driver, c.p. the manual:
http://www.php.net/pdo-mysql
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> PEAR All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement