sqlite, php, and Mac OS X 10.6.1

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

sqlite, php, and Mac OS X 10.6.1

FrankLane
Trying to write a test web page using php and sqlite. I have a Mac with OS X
10.6.1 (Snow Leopard). Maybe this is a php problem, Im not sure.

I have enabled web sharing, so I guess Apache is up and running. I have
un-commented out the line in /etc/apache2/httpd.conf which reads

  LoadModule php5_module        libexec/apache2/libphp5.so

I have written a program called test.php and when I bring it up in my
browser, I get a message: "cannot find driver". I think its having a problem
with the first line of the php program:

try {
  $dbHandle = new PDO('/Users/mymachine/sqlite:'."$user_db");
}
catch( PDOException $exception ){
  die($exception->getMessage());
}

I'm really new at this so Im hoping the problem is obvious. Thanks for any
help.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: sqlite, php, and Mac OS X 10.6.1

Swithun Crowe
Hello

PR try {
PR   $dbHandle = new PDO('/Users/mymachine/sqlite:'."$user_db");
PR }

How about:

$dbHandle = new PDO('sqlite:/Users/mymachine/'."$user_db");

The sqlite: should be at the beginning of the DSN (Data Source Name), so
that PDO can recognise the name of the driver to use.

Swithun.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: sqlite, php, and Mac OS X 10.6.1

Simon Slavin-3

On 11 Dec 2009, at 1:58pm, [hidden email] wrote:

> I have enabled web sharing, so I guess Apache is up and running. I have
> un-commented out the line in /etc/apache2/httpd.conf which reads
>
>  LoadModule php5_module        libexec/apache2/libphp5.so
>
> I have written a program called test.php and when I bring it up in my
> browser, I get a message: "cannot find driver". I think its having a problem
> with the first line of the php program:

Run the PHP INFO routine:

phpinfo();

and search for the word 'sqlite' in it.  You should fine it listed in the PDO section.  You should also see the following sections: 'pdo_sqlite', 'SQLite' and 'sqlite3'.  If any of those are missing you do not have sqlite enabled properly, possibly because of modules, possibly because of compilation options.


On 11 Dec 2009, at 2:03pm, Swithun Crowe wrote:

> $dbHandle = new PDO('sqlite:/Users/mymachine/'."$user_db");
>
> The sqlite: should be at the beginning of the DSN (Data Source Name), so
> that PDO can recognise the name of the driver to use.

Alternatively, use the native sqlite commands instead of the PDO driver:

http://php.net/manual/en/book.sqlite.php

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: sqlite, php, and Mac OS X 10.6.1

J. King-3
On Fri, 11 Dec 2009 09:13:33 -0500, Simon Slavin <[hidden email]>  
wrote:

> Run the PHP INFO routine:
>
> phpinfo();
>
> and search for the word 'sqlite' in it.  You should fine it listed in  
> the PDO section.  You should also see the following sections:  
> 'pdo_sqlite', 'SQLite' and 'sqlite3'.  If any of those are missing you  
> do not have sqlite enabled properly, possibly because of modules,  
> possibly because of compilation options.

Not exactly true: 'pdo_sqlite' and 'sqlite3' provide two independent  
interfaces to SQLite 3, and 'sqlite' provides an interface to SQLite 2.  
If you're missing -all- of them (or, realistically, only have 'sqlite'),  
then you're in trouble, but any of them missing could simply be a  
configuration choice.

> Alternatively, use the native sqlite commands instead of the PDO driver:
>
> http://php.net/manual/en/book.sqlite.php

For clarity, that's the old SQLite 2 interface---which I suspect you  
didn't intend to recommend, Simon.  The modern non-PDO SQLite 3 interface  
is documented here:

<http://www.php.net/manual/en/book.sqlite3.php>

It is, however, only available by default since PHP 5.3.0.

--
J. King
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users