473,386 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

SQL Stored Procedure from PHP

I'm trying to execute a SQL stored procedure from PHP like so:

$sql = "exec ('usp_Locations_Sel 5065')";

if (! $result = mssql_query($sql,$DBid))
{
exit;

}

while( $row = mssql_fetch_array($result) ){
// blah blah

}

The Procedure works from SQL Query Analyzer, and returns a result set
of 4 rows. Other stored procedures, in which a single variable is
declared for return, also come back to PHP without any problem.
However, any procedure that returns a result set doesn't make it back
to PHP.

(I don't have mssql_bind(), etc)

Any help would be much appreciated.
CL

Nov 22 '05 #1
4 1707
I'm trying to execute a SQL stored procedure from PHP like so: $sql = "exec ('usp_Locations_Sel 5065')"; However, any procedure that returns a result set doesn't make it back
to PHP.


Not sure what you mean by "doesn't make it back". Do you get a PHP
error or is your $result empty or something else?

One possibility is that your stored proc is trying to return more than
one resultset - usually because it is returning the number of rows
affected as a second resultset. The PHP API doesn't handle this. To
stop it, in the stored proc add this line before the start of your
code:

SET NOCOUNT ON

---
Steve

Nov 22 '05 #2
Steve,

I get no errors, no messages, it simply doesn't do anything.

I don't believe the proc was returning anything more than just the
single result set but I'll give that a shot.

I appreciate your help
Chad

Nov 22 '05 #3
I get no errors, no messages, it simply doesn't do anything.


Another possibility along the same lines is mentioned in the user note
by "brian_caughlin" in this man page:
<http://uk.php.net/manual/en/function.mssql-execute.php>.

---
Steve

Nov 22 '05 #4
SET NOCOUNT ON didn't help.

I am using PHP 4.3.4 with '--with-sybase=/usr/local/freetds' to access
the mssql functions and connect to SQL server.

I do not have the mssql functions mssql_next_result(),
mssql_execute(), mssql_bind().

Any suggestions would be greatly appreciated. I'm not getting very far
on this.

Thanks,
Chad

Nov 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: dinesh prasad | last post by:
I'm trying to use a servlet to process a form, then send that data to an SQL server stored procedure. I'm using the WebLogic 8 App. server. I am able to retrieve database information, so I know my...
0
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft...
3
by: Rhino | last post by:
I've spent the last couple of hours trying to figure out how to debug a Java stored procedure and am just going in circles. The last straw came when I got "Cannot open input stream for default"...
4
by: Rhino | last post by:
Is it possible for a Java Stored Procedure in DB2 V7.2 (Windows) to pass a Throwable back to the calling program as an OUT parameter? If yes, what datatype should I use when registering the...
8
by: Thomasb | last post by:
With a background in MS SQL Server programming I'm used to temporary tables. Have just started to work with DB2 ver 7 on z/OS and stumbled into the concept of GLOBAL TEMPORARY TABLE. I have...
2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
0
by: Amber | last post by:
Stored procedures are faster and more efficient than in-line SQL statements. In this article we will look at two SQL Server stored procedures; one using an input parameter and one not, and see how...
3
by: kd | last post by:
Hi All, How to debug a stored procedure? Thanks, kd
7
by: Dabbler | last post by:
I'm using an ObjectDataSource with a stored procedure and am getting the following error when trying to update (ExecuteNonQuery): System.Data.SqlClient.SqlException: Procedure or Function...
2
by: jed | last post by:
I have created this example in sqlexpress ALTER PROCEDURE . @annualtax FLOAT AS BEGIN SELECT begin1,end1,deductedamount,pecentageextra FROM tax
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.