1 utilisateur anonyme et 11 utilisateurs inconnus

 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

(PHP) Problèmes dans un script

n°7192
saturnium
Posté le 11-04-2007 à 16:46:41  profilanswer
 

Voila je dois me replonger dans le php et je vous avour cela fait longtemps. J'ai ici un script et j'ai beau relire, refaire et retester et cela ne marche pas. Je me doute que cela doit être un bétise mais j'ai trop relu ce script et je ne vois plus rien.  
 
Alors le probleme 1 est que dés que la variable mois passe à "08" (donc le mois d'aout ;)) et ben plus rien ne marche.
 
Et le probleme 2 est que les mises à jours sur la base SQL ne marche pas.
La table sql est structurée comme ceci :
 
mois,datea,img1,dateb,img2,datec,img3,dated,img4
 
Voila le script :

Citation :

<?
require("protect/connexion.php" );
$db_link = mysql_connect($host,$user,$pass);
 
 
$requete=mysql_db_query(tomboves,"select * from membresv12 where id=\"$id\"",$db_link);
 
if(mysql_num_rows($requete)==0)
 {
 header("Location:admigen_log_err.php" );
 }
 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>:: Administration : Agenda ::</title>
</head>
 
<body bgcolor="#000000" text="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">
<?
if ($action == 'voir')
  {
 
$i = 0;
if ($tmois == 01){
$amois = "Janvier";
};
if ($tmois == 02){
$amois = "Février";
};
if ($tmois == 03){
$amois = "Mars";
};
if ($tmois == 04){
$amois = "Avril";
};
if ($tmois == 05){
$amois = "Mai";
};
if ($tmois == 06){
$amois = "Juin";
};
if ($tmois == 07){
$amois = "Juillet";
};
if ($tmois == 08){
$amois = "Aout";
};
if ($tmois == 09){
$amois = "Septembre";
};
if ($tmois == 10){
$amois = "Octobre";
};
if ($tmois == 11){
$amois = "Novembre";
};
if ($tmois == 12){
$amois = "Décembre";
};
 
require("../connexion.php" );
$db_link = mysql_connect($host,$user,$pass);
mysql_select_db('tomboves',$db_link);  
$sql2=mysql_query("select * from agendav12 where mois='$tmois'",$db_link);
$datea = mysql_result($sql2,$i,"date1" );
$img1 = mysql_result($sql2,$i,"img1" );
$dateb = mysql_result($sql2,$i,"date2" );
$img2 = mysql_result($sql2,$i,"img2" );
$datec = mysql_result($sql2,$i,"date3" );
$img3 = mysql_result($sql2,$i,"img3" );
$dated = mysql_result($sql2,$i,"date4" );
$img4 = mysql_result($sql2,$i,"img4" );
if ($tmois == 12){
$moisp = "01";
};
if ($tmois == 11){
$moisp = "12";
};
if ($tmois == 10){
$moisp = "11";
};
if ($tmois == 09){
$moisp = "10";
};
if ($tmois == 08){
$moisp = "09";
};
if ($tmois == 07){
$moisp = "08";
};
if ($tmois == 06){
$moisp = "07";
};
if ($tmois == 05){
$moisp = "06";
};
if ($tmois == 04){
$moisp = "05";
};
if ($tmois == 03){
$moisp = "04";
};
if ($tmois == 02){
$moisp = "03";
};
if ($tmois == 01){
$moisp = "02";
};
if ($tmois == 12){
$moism = "11";
};
if ($tmois == 11){
$moism = "10";
};
if ($tmois == 10){
$moism = "09";
};
if ($tmois == 09){
$moism = "08";
};
if ($tmois == 08){
$moism = "07";
};
if ($tmois == 07){
$moism = "06";
};
if ($tmois == 06){
$moism = "05";
};
if ($tmois == 05){
$moism = "04";
};
if ($tmois == 04){
$moism = "03";
};
if ($tmois == 03){
$moism = "02";
};
if ($tmois == 02){
$moism = "01";
};
if ($tmois == 01){
$moism = "12";
};
echo "<center><table width='200' border='1' cellpadding='0' cellspacing='0' bordercolor='#FFFFFF'>
  <tr>
    <td><div align='center'>1</div></td>
    <td><div align='center'>2</div></td>
 <td><div align='center'>3</div></td>
 <td><div align='center'>4</div></td>
  </tr>
  <tr>
    <td><div align='center'>".$datea." ".$amois."</div></td>
    <td><div align='center'>".$dateb." ".$amois."</div></td>
 <td><div align='center'>".$datec." ".$amois."</div></td>
 <td><div align='center'>".$dated." ".$amois."</div></td>
  </tr>
  <tr>
    <td><img src='../mignature/agenda/".$img1."' width='104' height='104'/></td>
    <td><img src='../mignature/agenda/".$img2."' width='104' height='104'/></td>
 <td><img src='../mignature/agenda/".$img3."' width='104' height='104'/></td>
 <td><img src='../mignature/agenda/".$img4."' width='104' height='104'/></td>
  </tr>
  <tr>
    <td><div align='center'><a href='addagenda.php?id=".$id."&action=mod&dm=datea&d=".$datea."&i=img1&n=1&m=".$amois."&t=".$tmois."'>Modifier</a></div></td>
 <td><div align='center'><a href='addagenda.php?id=".$id."&action=mod&dm=dateb&d=".$dateb."&i=img2&n=2&m=".$amois."&t=".$tmois."'>Modifier</a></div></td>
 <td><div align='center'><a href='addagenda.php?id=".$id."&action=mod&dm=datec&d=".$datec."&i=img3&n=3&m=".$amois."&t=".$tmois."'>Modifier</a></div></td>
 <td><div align='center'><a href='addagenda.php?id=".$id."&action=mod&dm=dated&d=".$dated."&i=img4&n=4&m=".$amois."&t=".$tmois."'>Modifier</a></div></td>
  </tr>
  <tr>
    <td><a href='addagenda.php?id=".$id."&tmois=".$moism."&action=voir'>mois pr&eacute;c&eacute;dent</td>
 <td></td>
 <td></td>
    <td><div align='right'><a href='addagenda.php?id=".$id."&tmois=".$moisp."&action=voir'>mois suivant</div></td>
  </tr>
</table></center>";
echo "<a href='add.php?id=".$id."'>Retour vers la zone d'administration</a></center>";
};
if ($action == 'mod')
  {
echo "<form method='post' action='addagenda.php?id=".$id."&action=mod2&i=".$i."&t=".$t."'><center><table width='400' border='1' cellpadding='0' cellspacing='0' bordercolor='#FFFFFF'>
  <tr>
    <td><div align='center'>".$n."<br></div></td>
  </tr>
  <tr>
    <td><div align='center'>Mois :".$m."<br>Date : <input name='date' value='".$d."' type='text' />  
 </div></td>
  </tr>
  <tr>
    <td>Nom du fichier image :<input name='img' type='text' /><br><br><input type='submit' value='Envoyer'> </td>
  </tr>
</table></center></form>";
echo "<a href='add.php?id=".$id."'>Retour vers la zone d'administration</a></center>";
};
if ($action == 'mod2')
  {
 
require("../connexion.php" );
$v = 0;
$db_link = mysql_connect($host,$user,$pass);
mysql_select_db('tomboves',$db_link);  
$sql2=mysql_query("select * from agendav12 where mois='$t'",$db_link);
$datea = mysql_result($sql2,$v,"date1" );
$img1 = mysql_result($sql2,$v,"img1" );
$dateb = mysql_result($sql2,$v,"date2" );
$img2 = mysql_result($sql2,$v,"img2" );
$datec = mysql_result($sql2,$v,"date3" );
$img3 = mysql_result($sql2,$v,"img3" );
$dated = mysql_result($sql2,$v,"date4" );
$img4 = mysql_result($sql2,$v,"img4" );
$t = $m;
if ($i == 'img1')
  {
$db_link = mysql_connect($host,$user,$pass);
mysql_db_query('tomboves',"UPDATE agendav12 SET datea='$date',img1='$img' WHERE mois='$t'",$db_link);
echo "1";
};
if ($i == 'img2')
  {
$db_link = mysql_connect($host,$user,$pass);
mysql_db_query('tomboves',"UPDATE agendav12 SET dateb='$date',img2='$img' WHERE mois='$t'",$db_link);
echo "2";
};
if ($i == 'img3')
  {
$db_link = mysql_connect($host,$user,$pass);
mysql_db_query('tomboves',"UPDATE agendav12 SET datec='$date',img3='$img' WHERE mois='$t'",$db_link);
echo "3";
};
if ($i == 'img4')
  {
$db_link = mysql_connect($host,$user,$pass);
mysql_db_query('tomboves',"UPDATE agendav12 SET dated='$date',img4='$img' WHERE mois='$t'",$db_link);
echo "4";
};
mysql_close($db_link);
echo "<center>Le nom de l'image est :".$img."".$i."".$dated."<br>
Veuillez importer l'image de la vignette (Attention : elle doit avoir le m&ecirc;me nom que celui cit&eacute; juste avant) :<br>
<form method='post' action='addagenda.php?id=".$id."&action=up' ENCTYPE='multipart/form-data'>
<input type='file' name='file_name' enctype='multipart/form-data'><br>
<input type='hidden' name='MAX_FILE_SIZE' value='1000000'>
<input type='submit' value='Envoyer'><br><center>";
echo "<a href='add.php?id=".$id."'>Retour vers la zone d'administration</a></center>";
};
?>
 
 
<br />
 
</body>
</html>


 
Voila, merci de votre attention.  
Cela me dépanne pas mal.
La bonne fin de journée !


Message édité par saturnium le 12-04-2007 à 12:02:16
mood
Google
Posté le 11-04-2007 à 16:46:41  profilanswer
 

n°7193
Dr Lous
I see old password
Posté le 18-04-2007 à 12:59:26  profilanswer
 

au lieu de  
 

Code :
  1. $i = 0;
  2. if ($tmois == 01){
  3. $amois = "Janvier";
  4. };
  5. if ($tmois == 02){
  6. $amois = "Février";
  7. };
  8. if ($tmois == 03){
  9. $amois = "Mars";
  10. };
  11. if ($tmois == 04){
  12. $amois = "Avril";
  13. };
  14. if ($tmois == 05){
  15. $amois = "Mai";
  16. };
  17. if ($tmois == 06){
  18. $amois = "Juin";
  19. };
  20. if ($tmois == 07){
  21. $amois = "Juillet";
  22. };
  23. if ($tmois == 08){
  24. $amois = "Aout";
  25. };
  26. if ($tmois == 09){
  27. $amois = "Septembre";
  28. };
  29. if ($tmois == 10){
  30. $amois = "Octobre";
  31. };
  32. if ($tmois == 11){
  33. $amois = "Novembre";
  34. };
  35. if ($tmois == 12){
  36. $amois = "Décembre";
  37. };


 
utilise plutot (pas verifier, pas fait de php depuis un bon moment, mais le principe est la)

Code :
  1. $mois = {"janvier","fevrier","mars","avril", ...}
  2. $amois = $mois($tmois + 1)


 
ensuite je continue meme pas, c'est d'un goret ton code XD
 
pas de commentaire, pas de structuration, et pire que ca, des fonctions qui sont "on ne sait pk" là  
 
 
:(

n°7194
nicodache
marmotte en chocolat concept ©
Posté le 18-04-2007 à 19:56:21  profilanswer
 

j'osais pas le dire, mais effectivement, son code est porky powered :/


---------------
modérateur inside [:nicodache] plankaivoo [:nicodache] - ici powered - Je roule en micra 1l 55cv et je t'emmerde :o
mood
Google
Posté le 18-04-2007 à 19:56:21  profilanswer
 


Aller à :
Ajouter une réponse
 

Hit Parade