469,926 Members | 1,767 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,926 developers. It's quick & easy.

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 1223

Post your reply

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

Similar topics

2 posts views Thread by John Spiegel | last post: by
2 posts views Thread by mike | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.