Forum Moderators: coopster

Message Too Old, No Replies

search function conversion

Changing ASP pages to PHP

         

discosuperfly

2:02 pm on Apr 29, 2004 (gmt 0)

10+ Year Member



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.

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

Any help would be tremendous!

Troy

hakre

4:34 pm on Apr 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hi troy,

first of all

Request.Form("select")
and the similar ones will not work with php. use
[url=http://www.php.net/manual/en/reserved.variables.php#reserved.variables.request]$_REQUEST[/url]["select"]
instead.

for more information about getting the data of a form take a look here [php.net].

please correct this first and maybe the error is gone then.

--hakre