Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1652 connectés 

  FORUM HardWare.fr
  Programmation
  PHP

  Problème pour insérer des données sur MySQL

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Problème pour insérer des données sur MySQL

n°2238666
sfu_420
Posté le 23-09-2014 à 21:21:18  profilanswer
 

Bonjour, j'essaie de créer un calendrier pour capper (hmm on ne parle pas de p2p  ;) ) voilà mon projet http://tstn.no-ip.org/cap/october1.php
j'ai 2 fichiers .php, un october1.php principal qui représente le calendrier et october.php qui sert à envoyer les données et redirige vers october1.php
je me suis inspiré du site du Zéro avec le minichat
 
un détail du .php october1.php

Code :
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <meta charset="utf-8">
  5.     <title>NHL 2014/15 Schedule</title>
  6.    
  7.     <link rel="stylesheet" href="bordure.css">
  8. </head>
  9. <body>
  10. <h1 class="titre"><img src="avatars/nhl.png" alt="NHL"/>National Hockey League Schedule 2014/2015<img src="avatars/nhl.png" alt="NHL"/></h1>
  11. <table>
  12. <tr>
  13.  <th>Oct 8, 2014</th>
  14.  <th>HD stream<br/>720p Home</th>
  15.  <th>HD stream<br/>720p Away</th>
  16.  <th>HD<br/>720p Home</th>
  17.  <th>HD<br/>720p Away</th>
  18.  <th>HD Stream<br/>540p Home</th>
  19.  <th>HD Stream<br/>540p Away</th>
  20.  <th>NHL Tonight</th>
  21.  <th>Others Lang</th>
  22. </tr>
  23. <tr>
  24.  <th><img src="avatars/mont.gif" alt="Montréal"/>@<img src="avatars/tor.gif" alt="Toronto"/></th>
  25.  <th><form method="post" action="october.php">
  26.   <input type="text" name="pseudo" size="12" maxlength="12"/><br/>
  27.   <input type="submit" value="OK" />
  28.   </form>
  29. <?php
  30. try
  31. {
  32.  $bdd = new PDO('mysql:host=localhost;dbname=calendrier','root','xxxxxxx');
  33. }
  34. catch(Exception $e)
  35. {
  36.  die('Erreur : '.$e->getMessage());
  37. }
  38. $reponse = $bdd->query('SELECT pseudo FROM october1');
  39. {
  40.  echo htmlspecialchars($reponse['pseudo']);
  41. }
  42. ?>
  43.  </th>


 
october.php

Code :
  1. <?php
  2. try
  3. {
  4. $bdd = new PDO('mysql:host=localhost;dbname=calendrier','root','xxxxxxxx');
  5. }
  6. catch(Exception $e)
  7. {
  8. die('Erreur : '.$e->getMessage());
  9. }
  10. $req = $bdd->prepare('INSERT INTO october1 (pseudo) VALUES(?)');
  11. $req->execute(array($_POST['pseudo']));
  12. header('Location: october1.php');
  13. ?>

mood
Publicité
Posté le 23-09-2014 à 21:21:18  profilanswer
 

n°2238678
bistouille
Posté le 24-09-2014 à 06:41:44  profilanswer
 

$req = $bdd->prepare('INSERT INTO october1 (pseudo) VALUES(?)');
 
 :o

n°2238683
sfu_420
Posté le 24-09-2014 à 08:39:28  profilanswer
 

:heink: oui ? dans ma table que j'ai crée, j'ai une entrée pseudo quand chaque personne se rajoute, j'ai pas bon ?
j'ai oublié des ' ? ou autre chose ?

n°2239017
abracadebr​id
http://www.abracadebrid.com
Posté le 26-09-2014 à 16:47:26  profilanswer
 

http://sql.sh/cours/insert-into


---------------
http://www.abracadebrid.com débride 45 hébergeurs, uploaded, etc... Streaming purevid... gratuit sans java sans pubs.

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  PHP

  Problème pour insérer des données sur MySQL

 

Sujets relatifs
Création d'un thème basique sous WordPress : problème CSSLenteur MySQL
Problème affichage balises sous IEProbleme Avec un effet de slide
Problème Bash: permission deniedProbleme exo simple en C
[Résolu] Probleme execution de script php avec cronSelection d'intervalle de date et heure mysql
Problème RegEx et accentProblème basique HTML / CSS
Plus de sujets relatifs à : Problème pour insérer des données sur MySQL


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR