Se connecter avec
S'enregistrer | Connectez-vous

Probleme code php

Dernière réponse : dans Programmation

Salut a tous . Voila je vais ouvrir un site sur la guitare ,avec des videos .
Mais la j'ai un pb sur ma page d'administration .

Mais problème : quand je modifie ou ajoute une vidéo , rien n'est insrit dans la bdd . Je vous laisse voir par vous meme.
Le Liste_video.php
  1. Code : PHP
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" target="_blank">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</a>">
  3. <html xmlns="<a href="http://www.w3.org/1999/xhtml" target="_blank">http://www.w3.org/1999/xhtml</a>" xml:lang="fr" >
  4. <head>
  5. <title>Liste des Vidéos</title>
  6. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  7. <style type="text/css">
  8. h2, th, td
  9. {
  10. text-align:center;
  11. color:#black;
  12. font-family:Verdana, Arial, Helvetica, sans-serif
  13. font-size:10px;
  14. text-decoration:none;
  15. font-family: Verdana, Arial, Helvetica, sans-serif}
  16. }
  17. table
  18. {
  19. border-collapse:collapse;
  20. border:2px solid black;
  21. margin:auto;
  22. }
  23. th, td
  24. {
  25. border:1px solid black;
  26. }
  27. body
  28. {
  29. margin: 0 auto;
  30. padding: 0;
  31. font: 76% Verdana,Tahoma,Arial,sans-serif;
  32. background: url(images/marges/motif_bois.jpg);
  33. text-align:center;
  34. }
  35. </style>
  36.  
  37. <style type="text/css">
  38.  
  39.  
  40. </style>
  41. </head>
  42.  
  43. <body>
  44.  
  45.  
  46. <h2><a href="ajouter_video.php" ><u>Ajouter une vidéo</u></a></h2>
  47.  
  48. <?php
  49. mysql_connect("localhost", "root", "") ;
  50. mysql_select_db("vg");
  51.  
  52. //
  53.  
  54. if (isset($_POST['titre']) AND isset($_POST['lien']) AND isset($_POST['artiste']) AND isset($_POST['conseil']) AND isset($_POST['difficulte']))
  55. {
  56. $titre = addslashes($_POST['titre']);
  57. $conseil = addslashes($_POST['conseil']);
  58. $lien = addslashes($_POST['lien']);
  59. $artiste = addslashes($_POST['artiste']);
  60. $difficulte = addslashes($_POST['difficulte']);
  61.  
  62. if ($_POST['id_video'] == 0)
  63. {
  64.  
  65. mysql_query("INSERT INTO videos(id_video, titre , conseil, difficulté, lien, artiste) VALUES(' ' , '$titre' , '$conseil ' , '$difficulté' , '$lien' , '$artiste')");
  66. }
  67. else
  68. {
  69.  
  70. $_POST['id_video'] = addslashes($_POST['id_video']);
  71.  
  72. mysql_query("UPDATE videos SET titre='" . $titre . "', conseil='" . $conseil . "', lien='" . $lien . "', artiste='" . $artiste . "', difficulte='" . $difficulte . "' WHERE id_video='" . $_POST['id_video'] . "'");
  73. }
  74. }
  75.  
  76.  
  77.  
  78.  
  79. if (isset($_GET['supprimer_video']))
  80. {
  81.  
  82. $_GET['supprimer_video'] = addslashes($_GET['supprimer_video']);
  83. mysql_query('DELETE FROM video WHERE id_video=\'' . $_GET['supprimer_video'] . '\'');
  84. }
  85. ?>
  86.  
  87. <table><tr>
  88. <th>Modifier</th>
  89. <th>Supprimer</th>
  90. <th>Titre</th>
  91. <th>Artiste</th>
  92. <th>Lien</th>
  93. <th>Conseils</th>
  94. <th>Difficulté</th>
  95. </tr>
  96.  
  97. <?php
  98. $retour = mysql_query('SELECT * FROM videos ORDER BY id_video DESC') or die(mysql_error());
  99. while ($donnees = mysql_fetch_array($retour))
  100.  
  101. {
  102. ?>
  103.  
  104. <tr>
  105. <td><?php echo '<a href="ajouter_video.php?modifier_video=' . $donnees['id_video'] . '">'; ?>Modifier</a></td>
  106. <td><?php echo '<a href="liste_videos.php?supprimer_video=' . $donnees['id_video'] . '">'; ?>Supprimer</a></td>
  107. <td><?php echo stripslashes($donnees['titre']); ?></td>
  108. <td><?php echo stripslashes($donnees['artiste']); ?></td>
  109. <td><?php echo stripslashes($donnees['lien']); ?></td>
  110. <td><?php echo stripslashes($donnees['conseil']); ?></td>
  111. <td><?php echo ($donnees['difficulte']); ?></td>
  112. </tr>
  113.  
  114. <?php
  115. }
  116. mysql_close()
  117. ?>
  118. </table>
  119.  
  120. </body>
  121. </html>


Puis le ajouter_video.php
  1. Code : PHP
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" target="_blank">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</a>">
  3. <html xmlns="<a href="http://www.w3.org/1999/xhtml" target="_blank">http://www.w3.org/1999/xhtml</a>" xml:lang="fr" >
  4. <head>
  5. <title>Ajouter une vidéo</title>
  6. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  7. <style type="text/css">
  8. h3, h2, th, td
  9. {
  10. text-align:center;
  11. color:#black;
  12. font-family:Verdana, Arial, Helvetica, sans-serif
  13. font-size:10px;
  14. text-decoration:none;
  15. font-family: Verdana, Arial, Helvetica, sans-serif}
  16. }
  17. table
  18. {
  19. border-collapse:collapse;
  20. border:2px solid black;
  21. margin:auto;
  22. }
  23. th, td
  24. {
  25. border:1px solid black;
  26. }
  27. body
  28. {
  29. margin: 0 auto;
  30. padding: 0;
  31. font: 76% Verdana,Tahoma,Arial,sans-serif;
  32. background: url(images/marges/motif_bois.jpg);
  33. text-align:center;
  34. }
  35. </style>
  36. </head>
  37.  
  38. <body>
  39.  
  40. <h3><a href="liste_videos.php">Retour à la liste des vidéos</a></h3>
  41.  
  42. <?php
  43. mysql_connect("localhost", "root", "");
  44. mysql_select_db("vg");
  45.  
  46. if (isset($_GET['modifier_video']))
  47. {
  48.  
  49. $_GET['modifier_video'] = htmlentities($_GET['modifier_video'], ENT_QUOTES);
  50.  
  51. $retour = mysql_query('SELECT * FROM videos WHERE id_video=\'' . $_GET['modifier_video'] . '\'')or die(mysql_error());
  52. $donnees = mysql_fetch_array($retour);
  53.  
  54.  
  55. $titre = stripslashes($donnees['titre']);
  56. $artiste = stripslashes($donnees['artiste']);
  57. $conseil = stripslashes($donnees['conseil']);
  58. $lien = stripslashes($donnees['lien']);
  59. $difficulte = stripslashes($donnees['difficulte']);
  60. $id_video = $donnees['id_video'];
  61. }
  62. else
  63. {
  64.  
  65. $titre = '';
  66. $conseil ='';
  67. $lien = '';
  68. $artiste = '';
  69. $difficulte = '';
  70. $id_video = 0;
  71. }
  72. ?>
  73.  
  74. <form action="liste_videos.php" method="post">
  75. <p>Titre : <input type="text" size="30" name="Titre" value="<?php echo $titre; ?>" /></p>
  76. <p>Artiste : <input type="text" size="30" name="Artiste" value="<?php echo $artiste; ?>" /></p>
  77. <p>Lien : <input type="text" size="30" name="Lien" value="<?php echo $lien; ?>" /></p>
  78. <p>Difficulté : <input type="text" size="30" name="Difficulte" value="<?php echo $difficulte; ?>/10" /></p>
  79. <p>
  80. Conseils :<br />
  81. <textarea name="conseils" cols="50" rows="10">
  82. <?php echo $conseil; ?>
  83. </textarea><br />
  84.  
  85. <input type="hidden" name="id_video" value="<?php echo $id_video; ?>" />
  86. <input type="submit" value="Envoyer" />
  87. </p>
  88. </form>
  89.  
  90. </body>
  91. </html>



Merci d'avance .

Autres pages sur : probleme code php

Lassé par la pub ? Créez un compte

Bonjour,
je ne sais pas ou est le probleme,mais je peux te donner unconseil:
ajoute die(mysql_error()) quandtu fais des requestessur ta bdd, comme ca tu sais siil y a une erreur a ce niveau.
Exemple:
  1. mysql_query("BLABLABLA") or die(mysql_error());


Si il y a une erreur et que tu ne la comprends pas,re-poste un message ici avec l'erreur, on pourra surement te l'expliquer.

Bonne journée:) 
Lassé par la pub ? Créez un compte
Tom's guide dans le monde