Problème execution code php
dianroca
-
Defouille Messages postés 404 Statut Membre -
Defouille Messages postés 404 Statut Membre -
Bonjour,
Je developpe un site web et je souhaite recuperer les données à partir d'une bd mysql afin de pouvoir les utiliser. La connexion à la base marche bien mais lorsque je lance ma page (.php), c'est tout le code qui vient après les deux lignes de connection à la base et la selection qui est affiché. C'est comme si mon code php n'est pas bien executé.
Voici mon code:
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<title>Code php : echo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<h2>Code PHP</h2>
<p>
<?php
$host="localhost:3308";
$login="root";
$mp="";
$nom="stage";
try
{
$base=new PDO('mysql:host=localhost:3308;dbname=stage', 'root', '');
}
catch(Exception $e)
{
die('Erreur: ' .$e->getMessage());
}
//$rep=$base->query('select * from concept where idCpt <100');
$heure=$base->query('select heure_legale from lorient_1h_brut');
$debit=$base->query('select DUPLEIX_QTH_Debit_Traite_1h__A_ from lorient_1h_brut');
/*while($data=$rep->fetch())
{
echo $data['idCpt'] . '<br />';
}*/
while($data2=$heure->fetch())
{
//echo $data2['heure_legale'] . '<br />';
$date[]=$data2['heure_legale'];//tableau 1
}
$heure->closeCursor();
while($data3=$debit->fetch())
{
$deb[]=$data3['DUPLEIX_QTH_Debit_Traite_1h__A_']; //tableau 2
}
$debit->closeCursor();
$taillex=count(date);
$tailley=count(deb);
echo $taillex;
echo $tailley;
//$rep->closeCursor();
//echo "javascript:cercle();";
?>
</p>
</body>
</html>
Et voici ce qui est affiché lorsque je lance ma page:
Code PHP
getMessage()); } //$rep=$base->query('select * from concept where idCpt <100'); $heure=$base->query('select heure_legale from lorient_1h_brut'); $debit=$base->query('select DUPLEIX_QTH_Debit_Traite_1h__A_ from lorient_1h_brut'); /*while($data=$rep->fetch()) { echo $data['idCpt'] . '
'; }*/ while($data2=$heure->fetch()) { //echo $data2['heure_legale'] . '
'; $date[]=$data2['heure_legale'];//tableau 1 } $heure->closeCursor(); while($data3=$debit->fetch()) { $deb[]=$data3['DUPLEIX_QTH_Debit_Traite_1h__A_']; //tableau 2 } $debit->closeCursor(); $taillex=count(date); $tailley=count(deb); echo $taillex; echo $tailley; //$rep->closeCursor(); //echo "javascript:cercle();"; ?>
Si quelqu'un à une idée là dessus, elle sera la bienvenue.
Merci
Je developpe un site web et je souhaite recuperer les données à partir d'une bd mysql afin de pouvoir les utiliser. La connexion à la base marche bien mais lorsque je lance ma page (.php), c'est tout le code qui vient après les deux lignes de connection à la base et la selection qui est affiché. C'est comme si mon code php n'est pas bien executé.
Voici mon code:
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<title>Code php : echo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<h2>Code PHP</h2>
<p>
<?php
$host="localhost:3308";
$login="root";
$mp="";
$nom="stage";
try
{
$base=new PDO('mysql:host=localhost:3308;dbname=stage', 'root', '');
}
catch(Exception $e)
{
die('Erreur: ' .$e->getMessage());
}
//$rep=$base->query('select * from concept where idCpt <100');
$heure=$base->query('select heure_legale from lorient_1h_brut');
$debit=$base->query('select DUPLEIX_QTH_Debit_Traite_1h__A_ from lorient_1h_brut');
/*while($data=$rep->fetch())
{
echo $data['idCpt'] . '<br />';
}*/
while($data2=$heure->fetch())
{
//echo $data2['heure_legale'] . '<br />';
$date[]=$data2['heure_legale'];//tableau 1
}
$heure->closeCursor();
while($data3=$debit->fetch())
{
$deb[]=$data3['DUPLEIX_QTH_Debit_Traite_1h__A_']; //tableau 2
}
$debit->closeCursor();
$taillex=count(date);
$tailley=count(deb);
echo $taillex;
echo $tailley;
//$rep->closeCursor();
//echo "javascript:cercle();";
?>
</p>
</body>
</html>
Et voici ce qui est affiché lorsque je lance ma page:
Code PHP
getMessage()); } //$rep=$base->query('select * from concept where idCpt <100'); $heure=$base->query('select heure_legale from lorient_1h_brut'); $debit=$base->query('select DUPLEIX_QTH_Debit_Traite_1h__A_ from lorient_1h_brut'); /*while($data=$rep->fetch()) { echo $data['idCpt'] . '
'; }*/ while($data2=$heure->fetch()) { //echo $data2['heure_legale'] . '
'; $date[]=$data2['heure_legale'];//tableau 1 } $heure->closeCursor(); while($data3=$debit->fetch()) { $deb[]=$data3['DUPLEIX_QTH_Debit_Traite_1h__A_']; //tableau 2 } $debit->closeCursor(); $taillex=count(date); $tailley=count(deb); echo $taillex; echo $tailley; //$rep->closeCursor(); //echo "javascript:cercle();"; ?>
Si quelqu'un à une idée là dessus, elle sera la bienvenue.
Merci
A voir également:
- Problème execution code php
- Code ascii - Guide
- Code puk bloqué - Guide
- Comment déverrouiller un téléphone quand on a oublié le code - Guide
- Code activation windows 10 - Guide
- Code blocks - Télécharger - Langages