Error syntax php
Résolu
ciranox
Messages postés
387
Date d'inscription
Statut
Membre
Dernière intervention
-
__construct() -
__construct() -
Bonjour,
J'ai un code pour mon moteur de recherche. Quand je fais une recherche j'ai une erreur.
voici l'erreur :
Parse error: syntax error, unexpected ':' in C:\Users\Aimeric\Desktop\xampp\htdocs\ajax\search.php on line 18
voici mon code:
<?php
if(!empty($_POST)&& !empty($_POST['search']))
{
extract($_POST);
$search = strip_tags($search);
try{
$bdd = new PDO ('mysql:host=localhost;dbname=articles', 'aimeric','roffbmw94') or die(print_r($bdd->errorInfo()));
$bdd->exec('SET NAMES utf8');}
catch(exeption $e){
die('Erreur:'.$e->getMessage());
}
$req = $bdd->query("SELECT titre, contenu FROM articles WHERE titre LIKE'%$_search%' OR contenu LIKE'%search%' ORDER BY id");
if($req->rowCount()>0)
{
while($data = $req->fetch(PDO: :FETCH_OBJ))
{
echo '<h2>'.$data->titre.'</h2>';
echo '<p>'.$data->contenu.'</p>';
echo '<hr/>';
}
}
else
{
echo '<h2> Aucun resultat</h2>';
}
}
else
{
echo '<h2> Aucun resultat</h2>';
}
?>
https://gist.github.com/anonymous/813716
Merci d'avance.
J'ai un code pour mon moteur de recherche. Quand je fais une recherche j'ai une erreur.
voici l'erreur :
Parse error: syntax error, unexpected ':' in C:\Users\Aimeric\Desktop\xampp\htdocs\ajax\search.php on line 18
voici mon code:
<?php
if(!empty($_POST)&& !empty($_POST['search']))
{
extract($_POST);
$search = strip_tags($search);
try{
$bdd = new PDO ('mysql:host=localhost;dbname=articles', 'aimeric','roffbmw94') or die(print_r($bdd->errorInfo()));
$bdd->exec('SET NAMES utf8');}
catch(exeption $e){
die('Erreur:'.$e->getMessage());
}
$req = $bdd->query("SELECT titre, contenu FROM articles WHERE titre LIKE'%$_search%' OR contenu LIKE'%search%' ORDER BY id");
if($req->rowCount()>0)
{
while($data = $req->fetch(PDO: :FETCH_OBJ))
{
echo '<h2>'.$data->titre.'</h2>';
echo '<p>'.$data->contenu.'</p>';
echo '<hr/>';
}
}
else
{
echo '<h2> Aucun resultat</h2>';
}
}
else
{
echo '<h2> Aucun resultat</h2>';
}
?>
https://gist.github.com/anonymous/813716
Merci d'avance.
A voir également:
- Error syntax php
- Easy php - Télécharger - Divers Web & Internet
- Expert php pinterest - Télécharger - Langages
- Cmos checksum error ✓ - Forum Carte-mère/mémoire
- Playback error reconnect in 3s (1/5) francais - Forum Box et Streaming vidéo
- Whea error occt - Forum Processeur