PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » MDB2_Driver_mssql » Bug #9442

Quotes aren't being escaped using autoExecute

Details

Submitted2006-11-24 14:13 UTC
Frommatthijs at 1key dot nl
Assigneddavidc
StatusClosed
PackageMDB2_Driver_mssql
PHP Version5.1.6
OSWindows Server 2003
Roadmaps(Not assigned)

Comments

[2006-11-24 14:13 UTC] matthijs at 1key dot nl

Description:
------------
Software I'm using:
-Windows Server 2003 R2 Enterprise
-Apache
-Microsoft SQL Server 2005
-PHP 5.16
-PEAR 1.4.11
-MDB2 2.3.0
-MDB2_Driver_mssql 1.1.0

Installed pecl extensions:
-php_mssql.dll
-php_ldap.dll
-php_gd2.dll

Changes made to PHP.INI:
-mssql.textlimit = 2147483647
-mssql.textsize = 2147483647

----

In the previous version of MDB2 (2.2.2) there was no problem inserting strings containing single quotes ('). In the new version I get an error while inserting single quotes. I tried to use the escape and quote function but it had no use.

In the previous version I didn't escape the string at all. I just used autoExecute without escaping my string and that worked fine.

Test script:
---------------
$i_ResultId = 1;
$s_TextValue = "This doesn't work";

$s_TableName = 'CIS_TextResult';
$a_FieldsValues = array(
'resultId' => $i_ResultId,
'text' => $s_TextValue);

$a_Types = array('integer', 'text');
$s_Where = 'resultId = '.$i_ResultId;

$this->o_DatabaseController->loadModule('Extended');
$r_Result = $this->o_DatabaseController->extended->autoExecute($s_TableName, $a_FieldsValues, MDB2_AUTOQUERY_UPDATE, $s_Where, $a_Types);

if (PEAR::isError($r_Result))
throw new Exception ($r_Result->userinfo);

Expected result:
----------------
My row is succesfully updated...

Actual result:
--------------
[24-nov-2006 14:31:33] PHP Fatal error: Uncaught exception 'Exception' with message '[Error message: _doQuery: Could not execute statement]
[Last executed query: INSERT INTO CIS_TextResult (resultId, text) VALUES (13, 'This doesn't work')]
[Native code: 105]
[Native message: Unclosed quotation mark after the character string ')'.]
' in D:\websites\jbc.nl\core\cis\CISController.php:577
Stack trace:
#0 D:\websites\jbc.nl\core\cis\CISController.php(393): CISController->setTextResult(13, 'This doesn't wo...')
#1 D:\websites\jbc.nl\core\MainController.php(73): CISController->saveCISItem()
#2 D:\websites\jbc.nl\core\MainController.php(22): MainController->run()
#3 D:\websites\jbc.nl\index.php(3): MainController->__construct()
#4 {main}
thrown in D:\websites\jbc.nl\core\cis\CISController.php on line 577

[2006-11-27 11:19 UTC] matthijs at 1key dot nl

I don't think it's a bug in the driver since it worked fine in the previous MDB2 version and I didn't update the driver. I'm using autoExecute on very much places in my code so would really like to keep using it.

I tried to use the prepare() and execute() that also didn't work. It looks like the new MDB2 doesn't escape text at all.

[2007-01-10 13:44 UTC] matthijs at 1key dot nl

Hi David,

Sorry for responding this late. I didn't notice your message it was being kept in my junk mailbox. I tried to update the mdb2 driver and msb2 itself but it doesn't work. After updating every page on my website is blank. The error log doesn't show any errors.

What can I do to give you more information?

[2007-01-18 13:02 UTC] matthijs at 1key dot nl

It works! Thanks!