I have an Amazon style search box with a drop down box and a text box. Visitors can select to search by two different criteria. The page is currently an ASP page and it's working fine. I need to convert this to PHP and I'm using Dreamweaver MX. I've tried to redo the code using DW but I keep getting Parse Errors when I view the page.
Here is the .ASP code that works...
<%
Dim rsSearch__strDynamic
rsSearch__strDynamic = "0"
If (Request.Form("select") <> "") Then
rsSearch__strDynamic = Request.Form("select")
End If
%>
<%
Dim rsSearch__strSearch
rsSearch__strSearch = "1"
If (Request.Form("search") <> "") Then
rsSearch__strSearch = Request.Form("search")
End If
%>
<%
Dim rsSearch
Dim rsSearch_numRows
Set rsSearch = Server.CreateObject("ADODB.Recordset")
rsSearch.ActiveConnection = MM_trot_STRING
rsSearch.Source = "SELECT * FROM tblWebHorses WHERE " + Replace(rsSearch__strDynamic, "'", "''") + " REGEXP '[[:<:]]" + Replace(rsSearch__strSearch, "'", "''") + "'"
rsSearch.CursorType = 0
rsSearch.CursorLocation = 2
rsSearch.LockType = 1
rsSearch.Open()
rsSearch_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = 10
Repeat1__index = 0
rsSearch_numRows = rsSearch_numRows + Repeat1__numRows
%>
<%
Dim MM_paramName
%>
Here is the PHP that DW made for me...
<?php
$strDynamic_rsSearch = "0";
if (isset(Request.Form("select"))) {
$strDynamic_rsSearch = (get_magic_quotes_gpc())? Request.Form("select") : addslashes(Request.Form("select"));
}
$strSearch_rsSearch = "1";
if (isset(Request.Form("search"))) {
$strSearch_rsSearch = (get_magic_quotes_gpc())? Request.Form("search") : addslashes(Request.Form("search"));
}
mysql_select_db($database_trotphp, $trotphp);
$query_rsSearch = sprintf("SELECT * FROM tblWebHorses WHERE %s REGEXP '[[:<:]]%s'", $strDynamic_rsSearch,$strSearch_rsSearch);
$rsSearch = mysql_query($query_rsSearch, $trotphp) or die(mysql_error());
$row_rsSearch = mysql_fetch_assoc($rsSearch);
$totalRows_rsSearch = mysql_num_rows($rsSearch);
?>
Here is the error I get...
Parse error: parse error, expecting T_VARIABLE' or'$'' in /results.php on line 4
After searching for the same error I found some resolutions that talk about stripping out all the quotes and replacing them with apostrophes. I tried that but I get the exact same error..
Any help would be tremendous. Sorry for the long post!!
Troy