encode $searchenquiry
| From: | John Taylor-Johnston | Date: | Wed, 07 Jul 2004 17:58:21 +0000 |
| Subject: | encode $searchenquiry | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-189891@lists.php.net to get a copy of this message | ||
I have created an .inc that allows me to click on a submit to show the next or previous 25 records
found etc. The problem is that if $searchenquiry includes a quotation mark, the html looks like:
<input type="hidden" name="searchenquiry"
value=""atwood's" -margaret\">
Is there a function to encode $searchenquiry to do this?
<input type="hidden" name="searchenquiry"
value=""atwood's" -margaret\">
Or should I URLencode $searchenquiry or ... how should I approach this?
<input type=\"hidden\" name=\"searchenquiry\"
value=\"".$searchenquiry."\">
John
Here is a snippet. Ask and I will post it. Real easy to plug in.
$sql = 'SELECT *,MATCH (YR,AU,ST,SD,SC,BT,BD,BC,AT,AD,AC,JR,KW,AUS,GEO,AN,RB,CO,RR)
AGAINST (\''.stripslashes($searchenquiry).'\' IN BOOLEAN MODE)
AS relevancy FROM '.$table.'
WHERE MATCH (YR,AU,ST,SD,SC,BT,BD,BC,AT,AD,AC,JR,KW,AUS,GEO,AN,RB,CO,RR)
AGAINST (\''.stripslashes($searchenquiry).'\' IN BOOLEAN MODE)
ORDER BY relevancy DESC
LIMIT '.$offset.','.$limit.';';
if ($disp > 0)
{
$nextinsert = "<form ACTION=\"".$SCRIPT_NAME."\"
TARGET=\"_top\" METHOD=\"POST\"><td>Next ".$disp." Requests
<input type=\"submit\" name=\"submit\"
value=\">>\"><input type=\"hidden\" name=\"offset\"
value=\"".$new_offset."\"><input type=\"hidden\"
name=\"table\" value=\"".$table."\"><input
type=\"hidden\" name=\"db\" value=\"".$db."\">";
if($searchenquiry)
$nextinsert .= "<input type=\"hidden\" name=\"searchenquiry\"
value=\"".$searchenquiry."\">";
if($scholarsenquiry)
$nextinsert .= "<input type=\"hidden\" name=\"scholarsenquiry\"
value=\"".$scholarsenquiry."\">";
if($titlesenquiry)
$nextinsert .= "<input type=\"hidden\" name=\"titlesenquiry\"
value=\"".$titlesenquiry."\">";
$nextinsert .= "</td></form>";
}