1

I have the following PHP (thirdExampleConnector.php):

<?php
  require_once("/path/to/dhtmlx/dhtmlxConnector/codebase/grid_connector.php");
  require_once("/path/to/dhtmlx/dhtmlxConnector/codebase/db_pdo.php");

  $dbh = new PDO("mysql:host=127.0.0.1;port=3666;dbname=testdb", "root", "rootpw", array( PDO::ATTR_PERSISTENT => false));

  $conn = new GridConnector($dbh,"PDO");
  $conn->render_table("Writers","Id","Name");
?>

And it seems to work reasonably from the command line:

> php /path/to/verification/plans/app/thirdExampleConnector.php

<?xml version='1.0' encoding='utf-8' ?>
<rows><row id='1'><cell><![CDATA[Jack London]]></cell></row>
<row id='2'><cell><![CDATA[Honore de Balzac]]></cell></row>
<row id='3'><cell><![CDATA[Lion Feuchtwanger]]></cell></row>
<row id='4'><cell><![CDATA[Guy de Maupasant]]></cell></row>
<row id='5'><cell><![CDATA[Truman Capote]]></cell></row>
</rows>

But when I access it through the browser I get the error message:

 <br />
 <b>Fatal error</b>:  Uncaught exception 'PDOException' with message 'could not find driver' in /path/to/verification/plans/app/thirdExampleConnector.php:10
 Stack trace:
 #0 /path/to/verification/plans/app/thirdExampleConnector.php(10): PDO-&gt;__construct('mysql:host=loca...', 'root', 'rootpw')
 #1 {main}
 thrown in <b>/path/to/verification/plans/app/thirdExampleConnector.php</b> on line <b>10</b><br />

Here is the html file (if it makes any difference):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<html>
  <head>
    <link rel="STYLESHEET" type="text/css" href="../../../dhtmlx/dhtmlxGrid/codebase/dhtmlxgrid.css">
    <script src="../../../dhtmlx/dhtmlxGrid/codebase/dhtmlxcommon.js"></script>
    <script src="../../../dhtmlx/dhtmlxGrid/codebase/dhtmlxgrid.js"></script>
    <script src="../../../dhtmlx/dhtmlxGrid/codebase/dhtmlxgridcell.js"></script>
    <script src="../../../dhtmlx/dhtmlxDataProcessor/codebase/dhtmlxdataprocessor.js"></script>
    <script src="../../../dhtmlx/dhtmlxForm/codebase/dhtmlxform.js"></script>
    <script src="../../../dhtmlx/dhtmlxForm/samples/06_data/php/connector/connector.js"></script>
    <div id="box" style="width:350px; height:160px; background-color:white;"></div>
    <div id="box2" style="width:350px; height:100px; background-color:white;"></div>
  </head>
  <body>
    <script type="text/javascript">
      window.onload = function(){

        //---grid initialization
        var myGrid = new dhtmlXGridObject('box');          // object constructor
        myGrid.setHeader("Name");                          //specifies the grid's headers
        myGrid.setSkin("xp");                              //initializes the grid
        myGrid.init();                                     //initializes the grid
        myGrid.load("thirdExampleConnector.php");          //populates the grid with data from the DB

      }
    </script>
  </body>
</html>

One difference that I know of is that the web version of php is 5.2.5 and the command line version is 5.3.3 but I do not think I have any control over the which version of PHP the web server is using.

Is there a workaround for this?

stephenmm
  • 2,640
  • 3
  • 30
  • 48
  • possible duplicate of [PDOException “could not find driver”](http://stackoverflow.com/questions/2852748/pdoexception-could-not-find-driver) – Mike Dec 14 '13 at 22:21
  • p.s. PHP 5.2 is very old and you should definitely get that updated. Even 5.3 is getting on the old side. – Mike Dec 14 '13 at 22:24
  • In the other question 'PDOException “could not find driver”' the accepted answer talks about the module pdo_mysql but I do not have admin privileges on the server to install anything. Is there a workaround for this or do I have to rely on my pokey admins? – stephenmm Dec 14 '13 at 22:42
  • For instance is there a way to define from the php source code which version of php to use? Probably not but I thought it wouldn't hurt to ask. – stephenmm Dec 14 '13 at 23:04
  • You definitely won't be able to do this if you don't have admin access to the server. I would send your host a ticket and ask them to correctly install pdo_mysql for whatever version of PHP needs it. However the fact that they are using such outdated versions of PHP you might be better changing to another host that keeps their server software a bit more up to date. – Mike Dec 14 '13 at 23:23
  • And to answer your other question, no. You can't define which version of PHP to execute from within your PHP code. However you *may* be able to do this with [htaccess](http://stackoverflow.com/questions/12105632/change-php-version-on-server-using-either-htaccess-or-php-ini) (assuming Apache is the server). – Mike Dec 14 '13 at 23:26
  • Can't change hosts unless I get a new job... hmmm... I tried the htaccess trick 'AddHandler application/x-httpd-php53 .php' but it didn't work. It may be that my apache does not know that 5.3 is installed. Now need to figure out if *I* can tell apache what versions of PHP are available. Thanks for the help BTW. – stephenmm Dec 14 '13 at 23:37

0 Answers0