Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/05/2010, 16:44
den_22
 
Fecha de Ingreso: enero-2010
Mensajes: 198
Antigüedad: 14 años, 3 meses
Puntos: 1
el update no anda parece

Hola amigos, que tal?, estoy con un problema al que no le encuentro solución, explico mas o menos como es, tengo un codigo que sube imagenes a mi servidor, las imagenes se suben todo bien, tengo 4 campos en mi bd, picture (que es la imagen del perfil) image1, image2, image3. Cuando yo voy a tratar de editar esas fotos, por ejemplo me aparece que picture es la imagen del perfil, y si yo quiero poner una de las otras fotos como imagen de perfil, no puedo porque no se actualizan.
Es decir, quiero poder cambiar la image1 a picture, o la image2 a picture, con un checkbox. No sé que pasa que no funciona.
Dejo el codigo:

mostrarfotos.php:

Código PHP:
Ver original
  1. <?php
  2.  error_reporting(E_ALL ^ E_NOTICE);
  3. session_name('pLogin');
  4.  
  5. include("connect.php");
  6. include("function.php");
  7.  
  8. $usuario=$_SESSION["usuario"];
  9. $id=$_SESSION["id"];
  10.  
  11.  
  12. if ($defaultphoto == 'on') {
  13.  
  14.     mysql_query("update members set picture='$photo' where id='{$_SESSION[id]}'");
  15.  
  16. }
  17.  
  18.  
  19. if ($action == 'del') {
  20.  
  21.     $image1 = getimage1($id);
  22.  
  23.     $image2 = getimage2($id);
  24.  
  25.     $image3 = getimage3($id);
  26.  
  27.  
  28.     if ($picture == 'img1') {
  29.  
  30.         if (($image1 != '') and ($image2 != '') and ($image3 != '')) {
  31.  
  32.             @mysql_query("update members set image1='' where id='{$_SESSION[id]}'") or die(mysql_error
  33.                 ());
  34.  
  35.         } elseif (($image1 != '') and ($image2 != '') and ($image3 == '')) {
  36.  
  37.             @mysql_query("update members set image1='',picture='$image2' where id='{$_SESSION[id]}'") or
  38.                 die(mysql_error());
  39.  
  40.             unlink("images/" . $image1);
  41.  
  42.         } elseif (($image1 != '') and ($image3 != '') and ($image2 == '')) {
  43.  
  44.             @mysql_query("update members set image1='',picture='$image3' where id='{$_SESSION[id]}'") or
  45.                 die(mysql_error());
  46.  
  47.         } else {
  48.  
  49.             @mysql_query("update members set image1='',picture='' where id='{$_SESSION[id]}'") or
  50.                 die(mysql_error());
  51.  
  52.         }
  53.  
  54.  
  55.     }
  56.  
  57.  
  58.     if ($picture == 'img2') {
  59.  
  60.         if (($image1 != '') and ($image2 != '') and ($image3 != '')) {
  61.  
  62.             @mysql_query("update members set image2='' where id='{$_SESSION[id]}'") or die(mysql_error
  63.                 ());
  64.  
  65.         } elseif (($image1 != '') and ($image2 != '') and ($image3 == '')) {
  66.  
  67.             @mysql_query("update members set image2='',picture='$image1' where id='{$_SESSION[id]}'") or
  68.                 die(mysql_error());
  69.  
  70.             unlink("images/" . $image1);
  71.  
  72.         } else {
  73.  
  74.             @mysql_query("update members set image2='',picture='' where id='{$_SESSION[id]}'") or
  75.                 die(mysql_error());
  76.  
  77.         }
  78.  
  79.     }
  80.  
  81.     if ($picture== 'img3') {
  82.  
  83.         if (($image1 != '') and ($image2 != '') and ($image3 != '')) {
  84.  
  85.             @mysql_query("update members set image3='',picture='$image2' where id='{$_SESSION[id]}'") or
  86.                 die(mysql_error());
  87.  
  88.         } elseif (($image1 != '') and ($image3 != '') and ($image2 == '')) {
  89.  
  90.             @mysql_query("update members set image3='',picture='$image1' where id='{$_SESSION[id]}'") or
  91.                 die(mysql_error());
  92.  
  93.         } else {
  94.  
  95.             @mysql_query("update members set image3='',picture='' where id='{$_SESSION[id]}'") or
  96.                 die(mysql_error());
  97.  
  98.         }
  99.  
  100.     }
  101.  
  102. }
  103.  
  104.  
  105. $sql_photo = mysql_query("select * from members where id=$id");
  106.  
  107. $get_photo = mysql_fetch_array($sql_photo);
  108.  
  109. $defaultimg = $get_photo["picture"];
  110.  
  111. if ($get_photo["image1"] != '') {
  112.     if ($get_photo["image1"] != $defaultimg) {
  113.  
  114.     } else {
  115.  
  116.     }
  117.  
  118.  
  119. }
  120.  
  121. if ($get_photo["image2"] != '') {
  122.  
  123.     if ($get_photo["image2"] != $defaultimg) {
  124.  
  125.  
  126.     } else {
  127.  
  128.     }
  129.  
  130. }
  131.  
  132. if ($get_photo["image3"] != '') {
  133.  
  134.     if ($get_photo["image3"] != $defaultimg) {
  135.  
  136.     } else {
  137.  
  138.     }
  139.  
  140. }
  141.  
  142. if ($get_photo["image3"] == "" or $get_photo["image2"] == "" or $get_photo["image1"] ==
  143.     "") {
  144.  
  145. }
  146.  
  147. ?>

despues al lado de cada foto pongo algo asi, para que me indique si es la imagen que tengo en el perfil, o es otra imagen que tengo esto en el mismo codigo, pero está dentro del html:

Código PHP:
Ver original
  1. <?php
  2.  
  3.                                   if ($get_photo["image2"]!=$defaultimg)
  4.  
  5.                                   {
  6.  
  7.                                   ?>
  8.  
  9.                                   Mostrar en mi perfil
  10.  
  11.                                  
  12.                                   <?php
  13.  
  14.                                   }
  15.  
  16.                                   else
  17.  
  18.                                   {
  19.  
  20.                                   ?>
  21.  
  22.                                  Mostrar en mi perfil como la imagen por defecto
  23.    
  24.                                 <?php }?>


Este es el editar_foto.php:

Código PHP:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <?php
  5. error_reporting(E_ALL ^ E_NOTICE);
  6. session_name('pLogin');
  7.  
  8. include ("connect.php");
  9. include ("function.php");
  10.  
  11. $id=$_SESSION["id"];
  12. $usuario=$_SESSION["usuario"];
  13.  
  14.  
  15. $query = mysql_query("select * from members where usuario='$usuario'");
  16. $getname = mysql_fetch_array($query);
  17. $picture=$getname["picture"];
  18. $image1=$getname["image1"];
  19. $image2=$getname["image2"];
  20. $image3=$getname["image3"];
  21.  
  22.  
  23. if ($picture == 'picture') {
  24.     $cap = 1;
  25.  
  26.     $pic = 'pic';
  27.  
  28.     $picture = getpicture($id);
  29.  
  30.     $caption = $getname["picture"];
  31.  
  32. }elseif($picture =='image1'){
  33.  
  34. if ($picture == 'image1') {
  35.     $cap = 1;
  36.  
  37.     $img = 'img1';
  38.  
  39.     $image1 = getimage1($id);
  40.  
  41.     $caption = $getname["image1"];
  42.  
  43. } elseif ($picture == 'image2') {
  44.     $cap = 2;
  45.  
  46.     $img = 'img2';
  47.  
  48.     $image2 = getimage2($id);
  49.  
  50.     $caption = $getname["image2"];
  51.  
  52. } else {
  53.  
  54.     $cap = 3;
  55.  
  56.     $img = 'img3';
  57.  
  58.     $image3 = getimage3($id);
  59.  
  60.     $caption = $getname["image3"];
  61.  
  62. }
  63.  
  64. }
  65. ?>
  66. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  67. <title>Editar foto</title>
  68. <style type="text/css">
  69. <!--
  70. #Layer1 {
  71.     position:absolute;
  72.     left:155px;
  73.     top:60px;
  74.     width:557px;
  75.     height:264px;
  76.     z-index:1;
  77. }
  78. #Layer2 {
  79.     position:absolute;
  80.     left:155px;
  81.     top:100px;
  82.     width:80px;
  83.     height:20px;
  84.     z-index:2;
  85. }
  86. #Layer3 {
  87.     position:absolute;
  88.     left:244px;
  89.     top:100px;
  90.     width:422px;
  91.     height:135px;
  92.     z-index:3;
  93. }
  94. -->
  95. </style>
  96. </head>
  97.  
  98. <body>
  99. <div id="Layer1">
  100.   <p>Editar foto</p>
  101. </div>
  102. <div id="Layer2">Default foto: </div>
  103. <div id="Layer3">
  104. <form method=post action="misfotos.php">
  105. <tr>
  106.  
  107.                               <td class=body_txt bgcolor="#CCCCFF"></td>
  108.  
  109.                               <td class="body_txt" bgcolor="#CCCCFF">
  110.  
  111.                               <?php
  112.  
  113.                               if ($picture==getpicture($mid))
  114.  
  115.                               {
  116.  
  117.                               ?>
  118.  
  119.                               This is the default photo. To make a different photo the default click on<br>the <img src="images/edit_icon.gif" >icon to the right of the chosen photo.
  120.  
  121.                               <?php
  122.  
  123.                               }
  124.  
  125.                               else
  126.  
  127.                               {
  128.  
  129.                               ?>
  130.  
  131.                                 <input name=defaultphoto type=checkbox>
  132.  
  133.                                 Make this photo the default when viewing my profile.
  134.  
  135.                               <?php } ?>   
  136.  
  137.       </td>
  138. <input type="hidden" name="photo" value=<?php echo $image;?>>
  139.  
  140.                                     <input type="submit"  width="87" height="23">
  141.     </tr>
  142. </form>
  143. </div>
  144. </body>
  145. </html>

Gracias por leer.

den_22