I am trying to combine an if statement with a case statement which is needed to determine which submit button the user has clicked on the form from the previous page.
The form page
Code:<FORM ACTION="ordersearchresults.php" METHOD="GET" NAME="frmSearchCriteria"> <table class="searchtable"> <tr> <td class="leftside">Choose Category :</td> <td> <select name="type"> <option value="ordernumber">OrderNumber</option> <option value="partnumber">PartNumber</option> <option value="accountname">AccountName</option> </select> </td> </tr> <tr> <td class="leftside">Enter Keyword:</td> <td><input type="text" name="keyword"></td> </tr> <tr> <td class="leftside"><INPUT TYPE="Submit" name="exact match" VALUE="Exact Match"></td> <td class="leftside"><INPUT TYPE="Submit" name="contains" VALUE="Contains"></td> </tr> </FORM>
The following page is where I am getting my error
The lines in red are where the error is occurring and here is the errorCode:<?php require_once('databaseconnection.php'); $keywordentered = $_GET['keyword']; switch($_GET['type']) { case 'ordernumber': if ($_GET['contains']) { $result = odbc_exec($odbc, "SELECT * FROM orderpartnumbertable WHERE Order_No LIKE '".$keywordentered."%'"); } else { $result = odbc_exec($odbc, "SELECT * FROM orderpartnumbertable WHERE Order_No LIKE $keywordentered" ); } break; case 'partnumber': if ($_GET['contains']) { $result = odbc_exec($odbc, "SELECT * FROM orderpartnumbertable WHERE Part_No LIKE '".$keywordentered."%'"); } else { $result = odbc_exec($odbc, "SELECT * FROM orderpartnumbertable WHERE Part_No LIKE $keywordentered"); } break; case 'accountname': if ($_GET['contains']) { $result = odbc_exec($odbc, "SELECT * FROM orderpartnumbertable WHERE Account_Name LIKE '".$keywordentered."%'"); } else $result = odbc_exec($odbc, "SELECT * FROM orderpartnumbertable WHERE Account_Name LIKE $keywordentered" ); break; } echo '<table class="table">'; echo '<tr><th>Order Number</th><th>Part Number</th><th>Part Description</th><th>Order Quantity</th><th>Order Date</th><th>Account Name</th><th>More Info</th></tr>'; while (($row = odbc_fetch_array($result)) !== false) { echo '<tr>'; echo '<td>' . $row['Order_No'] . '</td>'; echo '<td>' . $row['Part_No'] . '</td>'; echo '<td>' . $row['Part_Description'] . '</td>'; echo '<td>' . $row['Order_Qty'] . '</td>'; echo '<td>' . $row['Order_Date'] . '</td>'; echo '<td>' . $row['Account_Name'] . '</td>'; echo '<td>' . '<a href="ordersearchdetails.php?fnp_site=' . rawurlencode($row['FNP_Site']) . '">More Info</a>' . '</td>'; echo '</tr>'; } echo '</table>'; ?>
This relates to the first red line but the second red line brings up the same error.Code:Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1., SQL state 07001 in SQLExecDirect in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\swiftdist\ordersearch\ordersearchresults.php on line 30








Bookmarks