Hello everyone. I have a database (SQL server 2008 R2) that I finally got PHP5 installed on. I Can run basic simple querries against the DB without problem. I am now trying to allow a user to search the database by drop down menus and text fields to narrow a search down and am running into a few problems. Any advice would be greatly appreciated.
Error Message:
Warning: sqlsrv_query() expects at least 2 parameters, 1 given in C:\Inetpub\wwwroot\msag\index.php on line 34
Here is the index.php File:
Ultimately I would like to be able to have several different drop boxes and text fields to search by. I thank you all in advance for your time and help.Code:<center><h1><u> MSAG Database </u></h1> <br> <br> <?php include 'includes/menu.php'; ?> <form method="post" action="index.php"> <input type="hidden" name="submitted" value="true" /> <label>Search Category: <select name="category"> <option value="StreetName">Street Name</option> </select> </label> <label>Search Criteria: <input type="text" name="criteria" /></label> <input type="submit" name="search" value="Search"/> </form> </center> <?php include 'includes/db/connect.php'; if(isset($_POST['search']) || isset($_POST['submit'])) { $category = $_POST['category']; $criteria = $_POST['criteria']; $query = "SELECT * FROM MSAG WHERE $category LIKE %$criteria% ORDER BY StreetName ASC"; $resource=sqlsrv_query($query); } ?> <form action="" method="post"> <table align="center" border="1" cellpadding="2" cellspacing="2" width="100%" > <tr align = 'center'> <td><b>Street Name</b></td> </tr> <?php while($result=sqlsrv_fetch_array($resource)) { echo " <tr align = center> <td>".$result['StreetName']."</td> <td><a href=\"modify2.php?id=".$result['StreetID']."\"><input type=\"button\" name = \"details\" value = \"Details\" /></a></td> </tr> "; } ?> </table> </form>



Reply With Quote

Bookmarks