Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #5097 > unrolled thread

php PDO does not work

Started bytest japan <testatjapan@gmail.com>
First post2012-03-03 07:10 -0800
Last post2012-03-05 08:04 -0500
Articles 6 — 4 participants

Back to article view | Back to comp.lang.php


Contents

  php PDO does not work test japan <testatjapan@gmail.com> - 2012-03-03 07:10 -0800
    Re: php PDO does not work Luuk <luuk@invalid.lan> - 2012-03-03 16:34 +0100
    Re: php PDO does not work Jerry Stuckle <jstucklex@attglobal.net> - 2012-03-03 12:59 -0500
      Re: php PDO does not work test japan <testatjapan@gmail.com> - 2012-03-03 17:08 -0800
    Re: php PDO does not work "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2012-03-05 10:23 +0100
      Re: php PDO does not work Jerry Stuckle <jstucklex@attglobal.net> - 2012-03-05 08:04 -0500

#5097 — php PDO does not work

Fromtest japan <testatjapan@gmail.com>
Date2012-03-03 07:10 -0800
Subjectphp PDO does not work
Message-ID<427252.950.1330787450521.JavaMail.geo-discussion-forums@pbcwi5>
i installed php and mysql on archlinux by pacman,
and in phpinfo page, i can see the infomation about mysql & pdo_mysql

in php.ini, i uncommented the following lines:
extension=mysqli.so
extension=mysql.so
extension=pdo_mysql.so

but when running the code below, the browser shows a blank page
no result, even no error message.

    try {
        $dbh = new PDO("mysql:host=192.168.0.1;dbname=testdb", "username", "password");
        echo 'Connected to database!!';
    } catch (PDOException ex) {
        echo $ex->getMessage();
   

anyone can help me?
thanks!

[toc] | [next] | [standalone]


#5098

FromLuuk <luuk@invalid.lan>
Date2012-03-03 16:34 +0100
Message-ID<l8q929-ti2.ln1@luuk.invalid.lan>
In reply to#5097
On 03-03-2012 16:10, test japan wrote:
> i installed php and mysql on archlinux by pacman,
> and in phpinfo page, i can see the infomation about mysql & pdo_mysql
> 
> in php.ini, i uncommented the following lines:
> extension=mysqli.so
> extension=mysql.so
> extension=pdo_mysql.so
> 
> but when running the code below, the browser shows a blank page
> no result, even no error message.
> 
>     try {
>         $dbh = new PDO("mysql:host=192.168.0.1;dbname=testdb", "username", "password");
>         echo 'Connected to database!!';
>     } catch (PDOException ex) {

change above line to:
} catch (PDOException $ex) {


>         echo $ex->getMessage();
>    
> 
> anyone can help me?
> thanks!

[toc] | [prev] | [next] | [standalone]


#5101

FromJerry Stuckle <jstucklex@attglobal.net>
Date2012-03-03 12:59 -0500
Message-ID<jitm60$nq2$1@dont-email.me>
In reply to#5097
On 3/3/2012 10:10 AM, test japan wrote:
> i installed php and mysql on archlinux by pacman,
> and in phpinfo page, i can see the infomation about mysql&  pdo_mysql
>
> in php.ini, i uncommented the following lines:
> extension=mysqli.so
> extension=mysql.so
> extension=pdo_mysql.so
>
> but when running the code below, the browser shows a blank page
> no result, even no error message.
>
>      try {
>          $dbh = new PDO("mysql:host=192.168.0.1;dbname=testdb", "username", "password");
>          echo 'Connected to database!!';
>      } catch (PDOException ex) {
>          echo $ex->getMessage();
>
>
> anyone can help me?
> thanks!

On your development system, enable error reporting and display the 
errors.  In your php.ini file you should have:

error_reporting = E_ALL
display_errors = on

Note you do NOT want to have display_errors=on in a production 
environment, and should log the errors instead.

Once you fix the syntax error(s) (Luuk found one - don't know if you 
have any others), you shouldn't get a blank page.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#5103

Fromtest japan <testatjapan@gmail.com>
Date2012-03-03 17:08 -0800
Message-ID<16398287.15.1330823299002.JavaMail.geo-discussion-forums@pbcuv8>
In reply to#5101
thanks for your help!

On Sunday, March 4, 2012 1:59:26 AM UTC+8, Jerry Stuckle wrote:
> On 3/3/2012 10:10 AM, test japan wrote:
> > i installed php and mysql on archlinux by pacman,
> > and in phpinfo page, i can see the infomation about mysql&  pdo_mysql
> >
> > in php.ini, i uncommented the following lines:
> > extension=mysqli.so
> > extension=mysql.so
> > extension=pdo_mysql.so
> >
> > but when running the code below, the browser shows a blank page
> > no result, even no error message.
> >
> >      try {
> >          $dbh = new PDO("mysql:host=192.168.0.1;dbname=testdb", "username", "password");
> >          echo 'Connected to database!!';
> >      } catch (PDOException ex) {
> >          echo $ex->getMessage();
> >
> >
> > anyone can help me?
> > thanks!
> 
> On your development system, enable error reporting and display the 
> errors.  In your php.ini file you should have:
> 
> error_reporting = E_ALL
> display_errors = on
> 
> Note you do NOT want to have display_errors=on in a production 
> environment, and should log the errors instead.
> 
> Once you fix the syntax error(s) (Luuk found one - don't know if you 
> have any others), you shouldn't get a blank page.
> 
> -- 
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstucklex@attglobal.net
> ==================



On Sunday, March 4, 2012 1:59:26 AM UTC+8, Jerry Stuckle wrote:
> On 3/3/2012 10:10 AM, test japan wrote:
> > i installed php and mysql on archlinux by pacman,
> > and in phpinfo page, i can see the infomation about mysql&  pdo_mysql
> >
> > in php.ini, i uncommented the following lines:
> > extension=mysqli.so
> > extension=mysql.so
> > extension=pdo_mysql.so
> >
> > but when running the code below, the browser shows a blank page
> > no result, even no error message.
> >
> >      try {
> >          $dbh = new PDO("mysql:host=192.168.0.1;dbname=testdb", "username", "password");
> >          echo 'Connected to database!!';
> >      } catch (PDOException ex) {
> >          echo $ex->getMessage();
> >
> >
> > anyone can help me?
> > thanks!
> 
> On your development system, enable error reporting and display the 
> errors.  In your php.ini file you should have:
> 
> error_reporting = E_ALL
> display_errors = on
> 
> Note you do NOT want to have display_errors=on in a production 
> environment, and should log the errors instead.
> 
> Once you fix the syntax error(s) (Luuk found one - don't know if you 
> have any others), you shouldn't get a blank page.
> 
> -- 
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstucklex@attglobal.net
> ==================

[toc] | [prev] | [next] | [standalone]


#5109

From"Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid>
Date2012-03-05 10:23 +0100
Message-ID<jj20mg$bbh$1@dont-email.me>
In reply to#5097
El 03/03/2012 16:10, test japan escribió/wrote:
> i installed php and mysql on archlinux by pacman,
> and in phpinfo page, i can see the infomation about mysql&  pdo_mysql
>
> in php.ini, i uncommented the following lines:
> extension=mysqli.so
> extension=mysql.so

As far as I know, these are unrelated to PDO.


> extension=pdo_mysql.so

Correct, this is the PDO driver for MySQL, though I don't really 
understand why pdo_mysql actually showed up in phpinfo() if this line 
was commented out :-?


> but when running the code below, the browser shows a blank page
> no result, even no error message.
>
>      try {
>          $dbh = new PDO("mysql:host=192.168.0.1;dbname=testdb", "username", "password");
>          echo 'Connected to database!!';
>      } catch (PDOException ex) {
>          echo $ex->getMessage();

Assuming there's a PHP start tag, you should be getting this:

Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE

I suggest you configure your development box to display all possible 
errors. You have several ways to do so:

1. Edit your "php.ini" file:

	error_reporting = E_ALL | E_STRICT
	display_errors = On

2. Put this on top of your script:

	<?php
	error_reporting(E_ALL | E_STRICT);
	ini_set('display_errors', TRUE);

3. If PHP runs as Apache module, you can also use an `.htaccess` file:

	# You cannot use PHP constants here
	php_value error_reporting -1
	php_flag display_errors on

This is not specifically related to PDO, it's how PHP error reporting 
works in general.



Additionally, PDO will not throw exceptions unless you tell it to 
because the default mode is PDO::ERRMODE_SILENT:

http://es2.php.net/manual/en/pdo.error-handling.php

This also implies that you cannot use exceptions to capture connection 
errors unless you set PDO::ERRMODE_EXCEPTION in the constructor.


-- 
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--

[toc] | [prev] | [next] | [standalone]


#5112

FromJerry Stuckle <jstucklex@attglobal.net>
Date2012-03-05 08:04 -0500
Message-ID<jj2dks$fjc$1@dont-email.me>
In reply to#5109
On 3/5/2012 4:23 AM, "Álvaro G. Vicario" wrote:
> El 03/03/2012 16:10, test japan escribió/wrote:
>> i installed php and mysql on archlinux by pacman,
>> and in phpinfo page, i can see the infomation about mysql& pdo_mysql
>>
>> in php.ini, i uncommented the following lines:
>> extension=mysqli.so
>> extension=mysql.so
>
> As far as I know, these are unrelated to PDO.
>
>
>> extension=pdo_mysql.so
>
> Correct, this is the PDO driver for MySQL, though I don't really
> understand why pdo_mysql actually showed up in phpinfo() if this line
> was commented out :-?
>
>
>> but when running the code below, the browser shows a blank page
>> no result, even no error message.
>>
>> try {
>> $dbh = new PDO("mysql:host=192.168.0.1;dbname=testdb", "username",
>> "password");
>> echo 'Connected to database!!';
>> } catch (PDOException ex) {
>> echo $ex->getMessage();
>
> Assuming there's a PHP start tag, you should be getting this:
>
> Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE
>
> I suggest you configure your development box to display all possible
> errors. You have several ways to do so:
>
> 1. Edit your "php.ini" file:
>
> error_reporting = E_ALL | E_STRICT
> display_errors = On
>
> 2. Put this on top of your script:
>
> <?php
> error_reporting(E_ALL | E_STRICT);
> ini_set('display_errors', TRUE);
>

This will not catch parse errors because the code is never executed.

> 3. If PHP runs as Apache module, you can also use an `.htaccess` file:
>
> # You cannot use PHP constants here
> php_value error_reporting -1
> php_flag display_errors on
>

The httpd.conf file must be set up to allow this, of course (I got 
caught on this one recently).

> This is not specifically related to PDO, it's how PHP error reporting
> works in general.
>
>
>
> Additionally, PDO will not throw exceptions unless you tell it to
> because the default mode is PDO::ERRMODE_SILENT:
>
> http://es2.php.net/manual/en/pdo.error-handling.php
>
> This also implies that you cannot use exceptions to capture connection
> errors unless you set PDO::ERRMODE_EXCEPTION in the constructor.
>
>


-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web