Php|Erreur dans une fonction php appelant PDO

Résolu/Fermé
ju571n - 22 déc. 2010 à 13:51
 ju571n - 22 déc. 2010 à 20:34
Bonjour,

J'ai un problème dans une fonction PHP. Je vous met le code et mon problème en dessous.
Fichier index.php
<?php include('includes/header.php'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
	<head>
		<?php include('includes/head.php'); ?>
	</head>
	<body>
	</body>
</html>


Fichier header.php
<?php
session_start();
try
{
    // On se connecte à MySQL
    $pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
    $bdd = new PDO('mysql:host=localhost;dbname=sg-online', 'root', '', $pdo_options);
}
catch(Exception $e)
{
    // En cas d'erreur précédemment, on affiche un message et on arrête tout
    die('Erreur (Connection MySql): '.$e->getMessage());
}
/*------------------------------------------------Fonction--*/
function utiliserOption($id,$type,$bdd)
{
	global $bdd;
	$reponse = $bdd->query("SELECT '$type' FROM site_options WHERE id='$id'");
	while ($donnees = $reponse->fetch())
	{
		echo ($donnees) ;
	}
	$reponse->closeCursor();
}
?>

Et le fichier head.php
<title><?php utiliserOption(1,'text',$bdd);?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />


Mon problème est que la fonction renvoie array dans la balise title

Pouvez vous m'aider ?

2 réponses

Zep3k!GnO Messages postés 2025 Date d'inscription jeudi 22 septembre 2005 Statut Membre Dernière intervention 18 novembre 2015 200
22 déc. 2010 à 14:42
Dans la fonction utiliserOption :
echo ($donnees[$type]) ;
0
merci, ça marche ;)
0