473,385 Members | 1,942 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,385 software developers and data experts.

PHP web form Call MSSQL stored procedure, display search results

geforceGTX480
So, I can't seem to get a sample code that works.
I have a web form that will have input fields. These fields will be used as input parameters for the MSSQL stored procedure.
From there we are expecting to get results depending on what
user is searching for.
I don't have access to view the stored procedure code, but I have execute permissions. Below is my code. I can successfully connect, but I do not get any results. In fact I get 0 results.
Is there anything I am missing? Can't use MySQL coz this is an IIS Server;
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // Connection settings
  3. $host = '#####';
  4. $user = '######';
  5. $pass = '######';
  6.  
  7. if ($conn = mssql_connect($host, $user, $pass)) // connection string
  8. {
  9. echo 'connected to Host <br/> ';
  10. }
  11.  
  12. // select database
  13. if (mssql_select_db('USAHerds', $conn)) { 
  14. echo ' and DB selected ';
  15. }
  16.  
  17.  
  18. $query = mssql_init("procAnimalBrandLicensesSearch", $conn) or die("Couldn't call stored procedure");
  19. $AcctFirstNames = $_GET['AcctFirstName'];
  20.  
  21. mssql_bind($query, "@AcctFirstName", $AcctFirstNames, SQLVARCHAR, FALSE, FALSE, 20);
  22.  
  23.  
  24. $result = mssql_execute($query);
  25.  
  26. $numProds = mssql_num_rows($result); 
  27.  
  28. echo "<h1>" . $numProds . " Result" . ($numProds == 0 ? "" : "s") . " Found for : $AcctFirstNames </h1><table border=\"1\"><tr>
  29.    <th>First Name</th>
  30.     <th>Last Name</th>
  31.     <th>File Name</th>
  32.   </tr>";
  33.  
  34. while($row = mssql_fetch_row($result)) 
  35.  
  36.  
  37. echo "<tr>" ."<td>" .$row["AcctFirstName"] ."</td>"."<td>". $row["AcctLastName"]."</td>". "<td>".$row["FileName"]. "</td>"."</tr>"; 
  38.  
  39. }
  40. echo "</table>";
  41.  
  42.  
  43. ?> 
  44.  
  45.  
Thanks for your help
Dec 21 '11 #1
0 1341

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Mamun | last post by:
Hi All, I have a stored procedure. I need to create a scheduled job using that stored procedure. I went to Enterprise Manager -->Management--> Jobs-->New Job Properties
2
by: John Spiegel | last post by:
Hi all, Any suggestions on the best way to pass a set of values to a stored procedure that will use them in a query? Specifically, I want to call a stored procedure from .NET that takes a set...
2
by: Josh Strickland | last post by:
I am attempting to create an Access database which uses forms to enter data. The issue I am having is returning the query results from the Stored Procedure back in to the Access Form. ...
2
by: mike | last post by:
H There are two ways to execute a stored procedure using ADO.NE - call "exec sp_myproc val1,val2" statement over SqlCommand myCommand = new SqlCommand(SQLQuery, mySqlConnection) - use...
0
by: IamtheEvster | last post by:
Hi All, I am currently using PHP 5 and MySQL 5, both on Fedora Core 5. I am unable to call a MySQL stored procedure that returns output parameters using mysql, mysqli, or PDO. I'm having a...
0
by: istruttorenuoto | last post by:
hi! I have some problems to call a stored procedure from an Unix Script. Here's the script stty istrip stty erase ^H export ORACLE_BASE=/product/oracle export...
2
Shashi Sadasivan
by: Shashi Sadasivan | last post by:
Hi All, I created a stored procedure which updates a specific row whose row ID is passed. But what I want to do now, (which is a one time requirement) is to update all rows is it possible to call...
2
by: Nexstar | last post by:
What is the fastest way to access the database for performance point of view? Should a .Net application call a stored procedure directly or should a .Net application call a web service, or use WCF,...
12
by: barmatt80 | last post by:
I don't know if this is the right part of the forum. But.... I have been working all night trying to create a web service to call a stored procedure in sql server 2008. The stored procedure calls...
5
by: kaushal30 | last post by:
I am getting this error when I call a stored procedure from my C# code. It is a simple stored procedure with six params that inserts data : PROCEDURE LHD_SUR_ADMNEXP_HDR_INS ( ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.