Help needed on a search
-
Hi,
I created a search form on this page: https://fgmtl.org/donner-give/en_US/1-form-rech/
It only says: <form action=”https://fgmtl.org/donner-give/2-resultats/” method=”post”>
<h3>Input a keyword in the search field below to see the corresponding Funds</h3>
<input name=”search” size=”50″ type=”text” placeholder=” Search your fund here ” /> <input type=”submit” value=”Search” /></form>On the Result Page I have the snippet code [xyz-ips snippet=”RecherchePHP4EN”]
The code in the Snippet being:$unwanted_array = array( ‘Š’=>’S’, ‘š’=>’s’, ‘Ž’=>’Z’, ‘ž’=>’z’, ‘À’=>’A’, ‘Á’=>’A’, ‘Â’=>’A’, ‘Ã’=>’A’, ‘Ä’=>’A’, ‘Å’=>’A’, ‘Æ’=>’A’, ‘Ç’=>’C’, ‘È’=>’E’, ‘É’=>’E’,
‘Ê’=>’E’, ‘Ë’=>’E’, ‘Ì’=>’I’, ‘Í’=>’I’, ‘Î’=>’I’, ‘Ï’=>’I’, ‘Ñ’=>’N’, ‘Ò’=>’O’, ‘Ó’=>’O’, ‘Ô’=>’O’, ‘Õ’=>’O’, ‘Ö’=>’O’, ‘Ø’=>’O’, ‘Ù’=>’U’,
‘Ú’=>’U’, ‘Û’=>’U’, ‘Ü’=>’U’, ‘Ý’=>’Y’, ‘Þ’=>’B’, ‘ß’=>’Ss’, ‘à’=>’a’, ‘á’=>’a’, ‘â’=>’a’, ‘ã’=>’a’, ‘ä’=>’a’, ‘å’=>’a’, ‘æ’=>’ae’, ‘ç’=>’c’,
‘è’=>’e’, ‘é’=>’e’, ‘ê’=>’e’, ‘ë’=>’e’, ‘ì’=>’i’, ‘í’=>’i’, ‘î’=>’i’, ‘ï’=>’i’, ‘ð’=>’o’, ‘ñ’=>’n’, ‘ò’=>’o’, ‘ó’=>’o’, ‘ô’=>’o’, ‘õ’=>’o’,
‘ö’=>’o’, ‘ø’=>’o’, ‘ù’=>’u’, ‘ú’=>’u’, ‘û’=>’u’, ‘ý’=>’y’, ‘þ’=>’b’, ‘ÿ’=>’y’ );
try
{
// On se connecte à MySQL
$bdd = new PDO(‘mysql:host=localhost;dbname=fgmtl_secteurs’, ‘MY_TABLE’, ‘MY_PASSWORD’);
$bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(Exception $e)
{
// En cas d’erreur, on affiche un message et on arrête tout
die(‘Erreur : ‘.$e->getMessage());
}
// Si tout va bien, on peut continuer// On récupère tout le contenu de la table secteurs
$search = htmlentities(strtr( $_POST[‘search’], $unwanted_array ), ENT_QUOTES, “UTF-8”);
$reponse = $bdd->query(“SELECT * FROM secteurs WHERE Nom_fr LIKE ‘%”.$search.”%’ OR Desc_fr LIKE ‘%”.$search.”%'”);
$reponse->execute();// On affiche chaque entrée une à une
while ($donnees = $reponse->fetch())
{
?>
<p><table bgcolor=”#efebe7″ width=”100%”><tr><td><h2><?php echo utf8_encode($donnees[‘Nom_fr’]); ?></h2>
<h3><?php echo utf8_encode($donnees[‘Desc_en’]); ?></h3>
<?php if($donnees[‘siteorg’] != ”)
{?>
” target = “_blank”><u><i>More on the organization</i></u><br />
<?php } ?>
<br />
” target = “_blank”>
<br />
</table>
</p>
<?php
}$reponse->closeCursor(); // Termine le traitement de la requête
====
But when you use the Search form, typing for example Ambulance, you get an error which is:
Notice: Undefined index: search in /var/www/vhosts/fgmtl.org/httpdocs/donner-give/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(65) : eval()’d code on line 21
And the result is not accurate.
Can someone point me on the right direction to know where the error comes from?
NB: My table and password are good and the search had worked well in the past but I don’t know what changed in the meantimeMany thanks in advance for your help!!
Valérie
The page I need help with: [log in to see the link]
The topic ‘Help needed on a search’ is closed to new replies.