Bonjour,
Hello,
I created a website to develop the adsl in my french village (yes, there are some village where we don't have the adsl
).
In order to put pressure on the mayor, I created a petition. For that, I created a sql base with 7 fields (id, firstname, surname, nickname, village, e-mail, comment) called artoinet_petition.
This database is completed by a form that redirected datas to the page "traitement-petition". This page complete the database like that :
<?php
// Connexion à la base de données
try
{
$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
$bdd = new PDO('mysql:host=ftp.artoisnet.elementfx.com;dbname=artoinet_petition', 'my id', 'my password', $pdo_options);
// Insertion du message dans la table
$req = $bdd->prepare('INSERT INTO petition (pseudo, prenom, nom, email, village, commentaire) VALUES(?, ?, ?, ?, ?, ?)');
$req->execute(array($_POST['pseudo'], $_POST['prenom'], $_POST['nom'], $_POST['email'], $_POST['village'], $_POST['commentaire']));
// Redirection du visiteur vers la page petition.php
header('Location: petition.php');
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
?>
Like that, the visitor is redirected to the page "petition.php" where we can see a table with their signatures
<?php
// Connexion à la base de données
try
{
$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
$bdd = new PDO('mysql:host=ftp.artoisnet.elementfx.com;dbname=artoinet_petition', 'Identifiant', 'Mon mot de passe', $pdo_options);
// Récupération des signatures
$reponse = $bdd->query('SELECT pseudo, village, commentaire FROM petition ORDER BY ID DESC LIMIT 0, 1000');
// Affichage de chaque signature
while ($donnees = $reponse->fetch())
{
echo '<p><table><tr><td><strong>Pseudo<strong></td><td><strong>Village</strong></td><td><strong>Commentaires</strong></td></tr><tr><td>' . htmlspecialchars($donnees['pseudo']) . '</td><td>' . htmlspecialchars($donnees['village']) . '</td><td>' . htmlspecialchars($donnees['commentaire']) . '</td></tr><table></p>';
}
$reponse->closeCursor();
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
?>
But it does not work, I have this error:
"Erreur : SQLSTATE[HY000] [2013] Lost connection to MySQL server at 'reading initial communication packet', system error: 111"
This is the link of my website:
http://artoisnet.elementfx.com/artoisn [...] /petition.php
Do you know how i can resolve this problem?
Thanks a lot!!
Greg
Hello,
I created a website to develop the adsl in my french village (yes, there are some village where we don't have the adsl
In order to put pressure on the mayor, I created a petition. For that, I created a sql base with 7 fields (id, firstname, surname, nickname, village, e-mail, comment) called artoinet_petition.
This database is completed by a form that redirected datas to the page "traitement-petition". This page complete the database like that :
<?php
// Connexion à la base de données
try
{
$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
$bdd = new PDO('mysql:host=ftp.artoisnet.elementfx.com;dbname=artoinet_petition', 'my id', 'my password', $pdo_options);
// Insertion du message dans la table
$req = $bdd->prepare('INSERT INTO petition (pseudo, prenom, nom, email, village, commentaire) VALUES(?, ?, ?, ?, ?, ?)');
$req->execute(array($_POST['pseudo'], $_POST['prenom'], $_POST['nom'], $_POST['email'], $_POST['village'], $_POST['commentaire']));
// Redirection du visiteur vers la page petition.php
header('Location: petition.php');
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
?>
Like that, the visitor is redirected to the page "petition.php" where we can see a table with their signatures
<?php
// Connexion à la base de données
try
{
$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
$bdd = new PDO('mysql:host=ftp.artoisnet.elementfx.com;dbname=artoinet_petition', 'Identifiant', 'Mon mot de passe', $pdo_options);
// Récupération des signatures
$reponse = $bdd->query('SELECT pseudo, village, commentaire FROM petition ORDER BY ID DESC LIMIT 0, 1000');
// Affichage de chaque signature
while ($donnees = $reponse->fetch())
{
echo '<p><table><tr><td><strong>Pseudo<strong></td><td><strong>Village</strong></td><td><strong>Commentaires</strong></td></tr><tr><td>' . htmlspecialchars($donnees['pseudo']) . '</td><td>' . htmlspecialchars($donnees['village']) . '</td><td>' . htmlspecialchars($donnees['commentaire']) . '</td></tr><table></p>';
}
$reponse->closeCursor();
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
?>
But it does not work, I have this error:
"Erreur : SQLSTATE[HY000] [2013] Lost connection to MySQL server at 'reading initial communication packet', system error: 111"
This is the link of my website:
http://artoisnet.elementfx.com/artoisn [...] /petition.php
Do you know how i can resolve this problem?
Thanks a lot!!
Greg