php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47803 Executing prepared statements is succesfull only for the first two statements
Submitted: 2009-03-27 09:10 UTC Modified: 2014-12-31 02:13 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: egil at wp dot pl Assigned:
Status: Closed Package: ODBC related
PHP Version: 5.2.9 OS: Windows XP SP 3
Private report: No CVE-ID: None
 [2009-03-27 09:10 UTC] egil at wp dot pl
Description:
------------
I do odbc_prepare and then I would like to be able to execute this statement with different paramas. This is what it is for, right? Fortunately not after 2 odbc_execute calls third call gives (mssql 2005 as you may see):
[Microsoft][SQL Native Client]Invalid character value for cast specification


Reproduce code:
---------------
<?
$sql = "UPDATE category
	SET name = ?
	WHERE cat_id = ?";
$result = $odbc_prepare($link, $sql);
if (!$result)
{
	trigger_error ('[sql] prep: '.$sql, E_USER_ERROR);
}
foreach ($upd_cats as &$k)
{
	if(!odbc_execute($result, array($k['name'], $k['id'])))
	{
		trigger_error ('[sql] exec: '."array({$k['name']}, {$k['id']})", E_USER_ERROR);
	}
}
?>

Expected result:
----------------
successful execution (note that it works fine if I move prepare to foreach block)

Actual result:
--------------
After third execution I get an error:
[Microsoft][SQL Native Client]Invalid character value for cast specification

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-29 10:18 UTC] tom dot graham at jadu dot co dot uk
I have exactly the same problem, two rows inserted fine and the third row is not inserted and the following error is thrown: "[Microsoft][ODBC SQL Server Driver]Invalid character value for cast specification".
 [2014-07-16 02:41 UTC] yohgaki@php.net
-Status: Open +Status: Feedback
 [2014-07-16 02:41 UTC] yohgaki@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.4-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2014-07-23 11:18 UTC] egil at wp dot pl
Still fails on 3rd execution.

Gist with test code (PHP) and test data (SQL):
https://gist.github.com/Eccenux/28ebf6c4a37d0e4a7c5f

Output:
> "c:\PHP-5.4-snap\php" -f "odbc_sql_test.php"
5.4.32-dev
Warning: odbc_execute(): SQL error: [Microsoft][ODBC SQL Server Driver]Błąd sekwencji funkcji, SQL state S1010 in SQLDescribeParameter in D:\_tmp\odbc_sql_test.php on line 60

Fatal error: [sql] exec: array(test 3, 3) in D:\_tmp\odbc_sql_test.php on line 62
 [2014-12-30 10:41 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2014-12-31 00:21 UTC] egil at wp dot pl
I think your robot is broken ;-). I provided the feedback - the problem still occurs.
 [2014-12-31 02:13 UTC] requinix@php.net
-Status: No Feedback +Status: Open
 [2014-12-31 02:13 UTC] requinix@php.net
You replied, yes, but left this in the Feedback state. Which is what the bot looks at.
 [2016-02-24 10:58 UTC] ab@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ff115e285ab5192f9e12a43d5dc202d88b01f1ea
Log: Fixed bug #47803
 [2016-02-24 10:58 UTC] ab@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC