OK I'm one of those designers that on occasion have to do the development myself. I'm no guru but it usually works. Not this time. I had a simple search function fully working in PHP but when the client switched servers on me ASP was required. Now I can't my PHP code to translate to ASP. Here is the code it reads a URL variable from a form via the POST method and performs a search on the database yielding the results. Can anyone help me rewrite this for ASP and an access database? <?php $search=$_POST["search"]; mysql_select_db($database_login, $login); $query_Recordset3 = "SELECT * FROM pmp WHERE dateadded LIKE '%$search%' OR filename LIKE '%$search%' OR discrip LIKE '%$search%'"; $Recordset3 = mysql_query($query_Recordset3, $login) or die(mysql_error()); $row_Recordset3 = mysql_fetch_assoc($Recordset3); $totalRows_Recordset3 = mysql_num_rows($Recordset3); ?> Thanks
Clasic ASP and I know I need to use OBDC I just can't get it to work correctly This is what I have <% Dim Recordset1 Dim Recordset1_cmd Dim Recordset1_numRows 'dim search search = CStr(Request("search")) Set Recordset1_cmd = Server.CreateObject ("ADODB.Command") Recordset1_cmd.ActiveConnection = MM_files_STRING Recordset1_cmd.CommandText = "SELECT * FROM pmp WHERE dateadded LIKE '& search &' OR filename LIKE ' & search & ' OR discrip LIKE '& search &'" Recordset1_cmd.Prepared = true Set Recordset1 = Recordset1_cmd.Execute Recordset1_numRows = 0 %> I think I'm close but I could be way off. Please Help. Thanks
There should be plenty of tutorials easily found on Google telling you how to use VBScript and MySQL Such as http://www.aspdev.org/articles/asp-mysql-connect/
I don't have a problem connecting to the database. I guess my question is how to call the url variable in the WHERE statement?
Off the top of my head, one thing I see wrong is that you aren't putting "*" around the search string (which is what Access likes where mySQL wants "%"). So you want to do search = "*" & search & "*" before the query string that includes it. Then the LIKE portions will work better.