php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40901 mssql_execute errror
Submitted: 2007-03-23 10:29 UTC Modified: 2009-03-03 01:00 UTC
Votes:4
Avg. Score:4.0 ± 1.0
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (33.3%)
From: lh at moranti dot com Assigned: fmk (profile)
Status: No Feedback Package: MSSQL related
PHP Version: 5.2.1 OS: ubuntu
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
29 - 11 = ?
Subscribe to this entry?

 
 [2007-03-23 10:29 UTC] lh at moranti dot com
Description:
------------
I have a problem executing a stored procedure. 
It fails on my ubuntu installation with php 5.2.1 but when i run it with php 5.1.6 no problem.

Reproduce code:
---------------
mssql_select_db("dbname", $conn);
$sp = mssql_init("procedurename", $conn); // stored proc name
	$compId=1000;
	$SessionId = substr(session_id(),0,8);
	
	mssql_bind($sp, "@CompID",$compId,SQLVARCHAR);
	mssql_bind($sp, "@SessionID",$SessionId,SQLVARCHAR);
	mssql_bind($sp, "@BasketAmount",$BasketAmount,SQLVARCHAR,TRUE);
	mssql_bind($sp, "@BasketTotalItem",$BasketTotalItem,SQLVARCHAR,TRUE);
	$query  = mssql_execute($sp) or die("could not perform insert");

Actual result:
--------------
Warning: mssql_execute() [function.mssql-execute]: stored procedure execution failed in /home/www/sitename/test_init.php on line 14

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-23 10:56 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2007-03-23 11:15 UTC] lh at moranti dot com
The storedprocedure looks like this:

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
CREATE PROCEDURE [dbo].[test]
(
   @sval int
) AS
return @sval+10


And the php code looks like this

<?
	$conn = mssql_connect("host","user","pass");
	mssql_select_db("dbscheme", $conn);
	
	$sp = mssql_init("test", $conn); // stored proc name
	$query  = mssql_execute($sp) or die("oops");

?>

is fails in this line "$query  = mssql_execute($sp) or die("oops");"
 [2007-03-23 11:20 UTC] lh at moranti dot com
Sorry the code schould look like this

<?
	$conn = mssql_connect("host","user","pass");
	mssql_select_db("dbscheme", $conn);
	$int=10;
	$sp = mssql_init("test", $conn); // stored proc name
	mssql_bind($sp, "@sval ",$int,SQLINT4);
	$query  = mssql_execute($sp) or die("oops");
?>
 [2007-03-23 17:34 UTC] fmk@php.net
I've tested your sample code and it works just fine om my system. I did modify it to get the return value back though:

$int=10;
$sp = mssql_init("test", $con); // stored proc name
mssql_bind($sp, "@sval", $int, SQLINT4);
mssql_bind($sp, "RETVAL", $ret, SQLINT4);
$query  = mssql_execute($sp) or die("oops");
echo "$ret\n";	
mssql_close($con);

 [2007-03-26 11:14 UTC] lh at moranti dot com
can i see your phpinfo ?
 [2009-02-24 00:50 UTC] kalle@php.net
Please try using this CVS snapshot:

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

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


 [2009-03-03 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2009-10-29 13:53 UTC] marcio dot muzzi at gmail dot com
I had the same problem and managed to solve as follows:

$sp = "procedurename";
$compId=1000;
$sql = "$sp $compId";
$query = mssql_query($sql);
$data = mssql_fetch_array($query);

This is not the most elegant way (do not use bind), but it works.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 08:01:28 2024 UTC