Page 1 of 1

PDO- select * fails while select colname returns result

PostPosted: 31. July 2009 07:47
by sucheta
Hello everybody,

I am running MySQL client version: 5.1.30 which has been bundled with
Xampp version 1.7.
This is the web server etc details under Xampp installation
* Apache/2.2.11 (Win32) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8i
mod_autoindex_color
PHP/5.2.8
* MySQL client version: 5.1.30
* PHP extension: mysql

The tables are of type InnoDB. And I am using PDO.

I have a query "select * from tablename" which runs fine under
phpmyadmin . It fails in
my php code. The error says "Apache needs to close, send error report".

In reality Apache doesn't close .
Also the same query "select Username from tablename" goes through as
expected. Here Username is a column name. The problem arises only when I
use PDO not otherwise.

Reproduce code:
---------------
$dbLink = $database->connectToDb();
if($dbLink instanceof PDO)
{
strStatement="SELECT * FROM user_login WHERE `Password`
='$encryptOldPwd'";
$result=$dbLink->query($strStatement)->fetch() ;
echo ($result[0]->UserName);
}

Expected result:
----------------
I expect to see the Username on the browser.

Actual result:
--------------
The browser shows a dialog box with error says "Apache needs to close,
send error report".
In reality Apache doesn't close .

When I click Do not send error , dialog box goes away and browser is
blank.

Thanks
Sucheta

Re: PDO- select * fails while select colname returns result

PostPosted: 03. August 2009 07:34
by sucheta
Hello everybody,

This problem is similar to #46289 PDO execute causes apache.exe to crash in the PECL forumhttp://bugs.php.net/bug.php?id=46289.
And the solution is also the same.

I fixed this problem on my computer. In my case it seems to have to do
something with the Xampp installation. It probably would be interesting
to know if the other people who were experiencing this problem were also
running on xampp. And this is the solution quoted there.

I found this solution by searching the web and found it on the
Magento-forum:
http://www.magentocommerce.com/boards/viewthread/31789/

The solution is simple:

- Download:
http://windows.php.net/downloads/snaps/ ... latest.zip
- Unzip & copy libmysql.dll into xampp\apache\bin & xampp\php.
- Restart apache.

I made the changes as above and my code works fine now.

Thanks
Sucheta