[PHP] Re: encode $searchenquiry
John Taylor-Johnston [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] 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=quot;atwood'squot; -margaret\ Or should I URLencode $searchenquiry or ... how should I approach this? input type=\hidden\ name=\searchenquiry\ value=\.$searchenquiry.\ John Hi John, you are looking for htmlentities(): http://de3.php.net/htmlentities Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: encode $searchenquiry
Or should I URLencode $searchenquiry or ... how should I approach this? Hi John, you are looking for htmlentities(): http://de3.php.net/htmlentities Regards, Torsten Roehr Torsten, Thanks. I think I'm going to start with htmlspecialchars(). htmlentities() might be over kill? Great :) John -- John Taylor-Johnston - If it's not open-source, it's Murphy's Law. ' ' ' Collège de Sherbrooke: ô¿ô http://www.collegesherbrooke.qc.ca/languesmodernes/ - Université de Sherbrooke: http://compcanlit.ca/ 819-569-2064 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: encode $searchenquiry
Torsten Here it is, if it is any use to you? John --- $sql = 'SELECT *,MATCH (KW,AUS) AGAINST (\''.stripslashes($searchenquiry).'\' IN BOOLEAN MODE) AS relevancy FROM '.$table.' WHERE MATCH (KW,AUS) AGAINST (\''.stripslashes($searchenquiry).'\' IN BOOLEAN MODE) ORDER BY relevancy DESC LIMIT '.$offset.','.$limit.';'; include (back_forth.inc); ?php ### ##back_forth.inc## # ## $mycounter is set by script calling settings_limit.inc # # ### Set $offset $limit # if((!$offset) || ($offset 0)) { $offset = 0; } $limit = 25; # ### $nextinsert # # $new_offset = $offset + $limit; $disp = $limit; if ($new_offset + $limit $mycounter) { $disp = $mycounter - $new_offset; } if ($disp 0) { $nextinsert = form ACTION=\.$SCRIPT_NAME.\ TARGET=\_top\ METHOD=\POST\tdNext .$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=\.htmlspecialchars($searchenquiry).\; if($scholarsenquiry) $nextinsert .= input type=\hidden\ name=\scholarsenquiry\ value=\.$scholarsenquiry.\; if($titlesenquiry) $nextinsert .= input type=\hidden\ name=\titlesenquiry\ value=\.$titlesenquiry.\; $nextinsert .= /td/form; } # ### $previousinsert # # $new_offset2 = $offset - $limit; if ($offset 0) // can display previous msg { $disp = $limit; $previousinsert = font face=\arial\ size=2A HREF=\index.html?submit=submitoffset=.$new_offset2.table=$tabledb=$db\lt;lt; Previous .$disp. Requests/a/font; $previousinsert = form ACTION=\.$SCRIPT_NAME.\ TARGET=\_top\ METHOD=\POST\tdinput type=\submit\ name=\submit\ value=\\ Previous .$disp. Requestsinput type=\hidden\ name=\offset\ value=\.$new_offset2.\input type=\hidden\ name=\table\ value=\.$table.\input type=\hidden\ name=\db\ value=\.$db.\; if($searchenquiry) $previousinsert .= input type=\hidden\ name=\searchenquiry\ value=\.htmlspecialchars($searchenquiry).\; if($scholarsenquiry) $previousinsert .= input type=\hidden\ name=\scholarsenquiry\ value=\.$scholarsenquiry.\; if($titlesenquiry) $previousinsert .= input type=\hidden\ name=\titlesenquiry\ value=\.$titlesenquiry.\; $previousinsert .= /td/form; } # ### $lastinsert # # $new_offset3 = $mycounter - $limit; if (($new_offset3 $limit) and ($offset != $mycounter - $limit)) // can display goto end msg { $lastinsert = form ACTION=\.$SCRIPT_NAME.\ TARGET=\_top\ METHOD=\POST\tdGo To End input type=\submit\ name=\submit\ value=\|\input type=\hidden\ name=\offset\ value=\.$new_offset3.\input type=\hidden\ name=\table\ value=\.$table.\input type=\hidden\ name=\db\ value=\.$db.\; if($searchenquiry) $lastinsert .= input type=\hidden\ name=\searchenquiry\ value=\.htmlspecialchars($searchenquiry).\; if($scholarsenquiry) $lastinsert .= input type=\hidden\ name=\scholarsenquiry\ value=\.$scholarsenquiry.\; if($titlesenquiry) $lastinsert .= input type=\hidden\ name=\titlesenquiry\ value=\.$titlesenquiry.\; $lastinsert .= /td/form; } # ### $firstinsert # $new_offset4 = $mycounter - $limit; if ($new_offset4 $limit) // can display goto beginning msg { $new_offset4 = 0; $firstinsert = form ACTION=\.$SCRIPT_NAME.\ TARGET=\_top\ METHOD=\POST\tdinput type=\submit\ name=\submit\ value=\|\ Go To Beginninginput type=\hidden\ name=\offset\ value=\.$new_offset4.\input type=\hidden\ name=\table\ value=\.$table.\input type=\hidden\ name=\db\ value=\.$db.\; if($searchenquiry) $firstinsert .= input type=\hidden\ name=\searchenquiry\ value=\.htmlspecialchars($searchenquiry).\; if($scholarsenquiry) $firstinsert .= input type=\hidden\ name=\scholarsenquiry\ value=\.$scholarsenquiry.\; if($titlesenquiry) $firstinsert .= input type=\hidden\ name=\titlesenquiry\ value=\.$titlesenquiry.\; $firstinsert .= /td/form; } # ### Display Inserts