|  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
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
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


Add a Patch

Pull Requests

Add a Pull Request


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]
-Status: Open +Status: Feedback
 [2014-07-16 02:41 UTC]
Please try using this snapshot:
For Windows:

 [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):

> "c:\PHP-5.4-snap\php" -f "odbc_sql_test.php"
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]
-Status: No Feedback +Status: Open
 [2014-12-31 02:13 UTC]
You replied, yes, but left this in the Feedback state. Which is what the bot looks at.
 [2016-02-24 10:58 UTC]
Automatic comment on behalf of ab
Log: Fixed bug #47803
 [2016-02-24 10:58 UTC]
-Status: Open +Status: Closed
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Nov 29 06:01:28 2023 UTC