Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/10/2008, 22:12
Avatar de ajalex
ajalex
 
Fecha de Ingreso: agosto-2003
Mensajes: 122
Antigüedad: 20 años, 8 meses
Puntos: 0
Exclamación Ayuda con multiples mensajes dentro de un function

hola que tal! de nuevo aqui molestando, resulta que estoy haciendo una programacion para anadir multiples fotos a un server e insertarla dentro de una base de datos.. funciona perfectamente incluso me da los mensajes si una subio y la otra no, perfectamente. el problema es cuando en ves de hacer un echo para mostrar el error, pongo un ej: $status, para mostrarlo dentro de otra funcion

osea: tengo mi formulario para subir las fotoS:
Código PHP:
<?
function add_photos_mass($meggage_update,$tot){
global 
$db;
submenu($current 'add_photos_mass');
         for (
$i 0$i $tot$i++){
echo 
$meggage_update;
}
?>
<script type="text/javascript">
var numero = 0; 
evento = function (evt) {
   return (!evt) ? event : evt;
}
addCampo = function () { 
   nDiv = document.createElement('div');
   nDiv.className = 'archivo';
   nDiv.id = 'file' + (++numero);
   nCampo = document.createElement('input');
   nCampo.name = 'archivos[]';
   nCampo.type = 'file';
   a = document.createElement('a');
   a.name = nDiv.id;
   a.href = '#';
   a.onclick = elimCamp;
   a.innerHTML = 'Eliminar';
   nDiv.appendChild(nCampo);
   nDiv.appendChild(a);
   container = document.getElementById('adjuntos');
   container.appendChild(nDiv);
}
elimCamp = function (evt){
   evt = evento(evt);
   nCampo = rObj(evt);
   div = document.getElementById(nCampo.name);
   div.parentNode.removeChild(div);
}
rObj = function (evt) { 
   return evt.srcElement ?  evt.srcElement : evt.target;
}
</script>
<div class="wrap">
<h2>Añadir Fotográfias masivamente</h2>
 <form name="formu" id="formu" action="galeria.php" method="post" enctype="multipart/form-data">

<table class="form-table">
<tr valign="top">
  <th colspan="2" scope="row">Agregar Fotográfias a una galería</th>
  </tr>
<tr valign="top">
  <th scope="row">Galería</th>
  <td><?
    $result2
=$db->query("select cid, title, parentid from normal_gallery_categories order by parentid,title");
    echo 
"<select name=\"gid\">\r\n";
    while(list(
$cid2$ctitle2$parentid2) = $db->fetch_row($result2)) {
        if (
$parentid2!=0$ctitle2=getparent($parentid2,$ctitle2);
        echo 
"<option value=\"$cid2\">$ctitle2</option>\r\n";
    }
    echo 
"</select>\r\n<br>";
    
?></td>
</tr>
<tr valign="top">
  <th scope="row">Foto</th>
  <td><label>
       <div id="adjuntos">
   <input type="file" name="archivos[]" /><br />
   </div>
      <dt><a href="#" onClick="addCampo()">Subir otro archivo</a></dt>
  </label></td>
</tr>
<tr valign="top">
  <th scope="row">Fecha</th>
  <td><input id="date" name="date" type="text" class="DatePicker" tabindex="1" value="<? echo date("Y-m-d")?>" /></td>
</tr>
<tr valign="top">
  <th scope="row">Hola</th>
  <td><input id="time" name="time" type="text" class="TimePicker" tabindex="1" value="<? echo date("H:m:s")?>" />
Formato de 24 Horas ej: 15:40:00 para 3:40:00</td>
</tr>
</table>
<input type="hidden" name="task" value="add_photo_save_mass" />

<p class="submit"><input type="submit" name="Submit" value="Agregar" />
</p>
</form>
</div>
<?
}
?>
ahi me manda a otra funcion que es la de la upload e inserta a la DB

Código PHP:
<?
function add_photo_save_mass($gid,$archivos,$date,$time){
global 
$db;
         if (isset (
$_FILES["archivos"])) {
         
$tot count($_FILES["archivos"]["name"]);
         for (
$i 0$i $tot$i++){

            
$tmp_name $_FILES["archivos"]["tmp_name"][$i];
            
$name $_FILES["archivos"]["name"][$i];
            
$prefijo substr(md5(uniqid(rand())),0,20);
            if (
$_FILES["archivos"] != "") {
    
$result=$db->query("select cid, link_html, parentid from normal_gallery_categories where cid='$gid'");
    while(list(
$cid2$clink_html2$parentid2) = $db->fetch_row($result)) {
        if (
$parentid2!=0$clink_html2=get_html($parentid2,$clink_html2);
        
$path "$clink_html2";
    }
            
$destino =  "../gallery/$path/".$prefijo."_".$name;
            if (
copy($tmp_name,$destino)) {
            
$foto $prefijo."_".$name;
            
$fecha "$date $time";
$result $db->query("INSERT INTO `normal_gallery_gallery` set `gid`='$gid',`image`='$foto',`datetime`='$fecha'");
            
$status "<br/><div id=\"message\" class=\"updated fade\">    <ul>
    <li><strong>$name</strong>: subio con exito</li>    </ul></div><br/>"
;
            } else {
            
$status "<div class=\"error\">
    <ul>
    <li><strong>ERROR</strong>: Error al subir la foto: $name</li>    </ul>
</div>
<br/>"
;
            }
            } else {
            
$status "<div class=\"error\">
    <ul>
    <li><strong>ERROR</strong>: Error al subir la foto: $name</li>    </ul>
</div>
<br/><br/>"
;
            }            
            }
      } 
            
add_photos_mass($status,$tot); 

}
?>
y este es el swich una parte:

Código PHP:
switch ($task) {

    case 
"edit_photo_save":
    
edit_photo_save($cid,$titulo,$gid,$cdescripcion,$date,$time);
    break;
    
    case 
"edit_photo":
    
edit_photo($cid);
    break;
    
    case 
"edit_photos":
    
edit_photos($pg,$meggage_update);
    break;

    case 
"add_photos_mass":
    
add_photos_mass($meggage_update,$tot);
    break; 
como ven en add_photo_mass hasta abajo tengo la funcion de mi formulario para mostralo al anadir la foto y ahi en add_photos_mass tengo un echo con $meggage_update que es donde muestra le mensaje si subio o no, pero solamente me da el mensaje de la ultima que subio, le hize un cambio como ven tiene un bucle y funciona, me da todos los mensajes de las fotos que suba, pero error!! es el mismo mensaje en todos,!!!

alguien que me auxilie, se los agradeceria!!!!