Foros del Web » Programando para Internet » PHP »

problema para cargar info en la bd

Estas en el tema de problema para cargar info en la bd en el foro de PHP en Foros del Web. bueno, ademas del topic que cree recien.. tengo otro problema (este nunca en mas de dos años habia sucedido) cuando quiero cargar una propiedad, no ...
  #1 (permalink)  
Antiguo 29/06/2010, 03:21
 
Fecha de Ingreso: enero-2007
Mensajes: 135
Antigüedad: 17 años, 3 meses
Puntos: 1
problema para cargar info en la bd

bueno, ademas del topic que cree recien..
tengo otro problema (este nunca en mas de dos años habia sucedido)
cuando quiero cargar una propiedad, no carga a la bd ningun campo..
me estoy volviendo loco.. eso siempre funciono.. no se porque ahora no lo hace...
les paso el codigo (traten de no burlarse la hice hace mucho tiempo)
basicamente carga los datos de una propiedad en una tabla y genera un "reporte" en xls con los datos.
alguien se le ocurre porque puede ser que no funcione mas y antes lo hacia sin ningun problema?
NO TENGO IDEA QUE PUEDE SER...
lo mas extraño es que tengo backup de todo el site de mas de un año y cuando los recupero ahora no andan..
me quiero matar... llevo mas de 16 horas sin parar..
saludos y desde ya gracias
Manu
Código PHP:
<? 
/*****Creado por: [email protected]*****/ 


$server="localhost";              /* Nuestro server mysql:  */ 
$database="inmobili_";               /* Nuestra base de datos */ 
$dbpass="******";               /*Nuestro password */ 
$dbuser="inmobili_";                 /* Nuestro user  */


//datos del arhivo 
$nombre_archivo $HTTP_POST_FILES["userfile"]["name"]; 
$tipo_archivo $HTTP_POST_FILES["userfile"]["type"]; 
$tamano_archivo $HTTP_POST_FILES["userfile"]["size"]; 

//compruebo si las características del archivo son las que deseo 

if (!((strpos($tipo_archivo"gif") || strpos($tipo_archivo"jpeg")) && (    $tamano_archivo 100000))&& ($nombre_archivo !=''))

    echo 
"La extensión o el tamaño de los archivos no es correcta. <br><br><table><tr><td><li>Se permiten archivos .gif o .jpg<br><li>se permiten archivos de 100 Kb máximo.</td></tr></table>";
?>
    <script language="javascript">
        setTimeout("url()",3000);
        function url()
        {
        window.history.back();
        }
    </script>           
<?    
}
else

    
$nom_img$nombre_archivo;
    
$ruta'imagenes/'.$codigo.'/'.$nom_img;
    
$directorio '../'.'imagenes/'.$codigo;
    
$directorio2 'imagenes/'.$codigo;

if (!
is_dir($directorio)) {
  if (!
mkdir($directorio))
          die (
"El directorio no existe o no puede crearse");
  if (!
chmod($directorio,0777))
      die (
"Fallo el cambio de permisos a 0777.");}
    if (
move_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'],$directorio "/" $nom_img)||($nombre_archivo ==''))
    { 
            
$diaactualdate("d"); 
        
$mesactualdate("m"); 
        
$anoactualdate("Y");
        
$fecha$diaactual "/" $mesactual "/" $anoactual;
        
        
//NOS CONECTAMOS A LA BASE DE DATOS

        
$link=mysql_connect($server,$dbuser,$dbpass);
                        
        
$query"INSERT INTO galeria (codigo, Foto, Operación, tipo, precio, barrio, localidad,
estado, caracteristicas, comodidades, servicios, notas, consultas, conosca, plano, puntos, video, honorarios, agua, catastral, manzana, lotes, renta, muni, base, dominio, vendedor, domicilio, telefono, mail) 

VALUES ('$codigo', '$ruta', '$operacion', '$tipo', '$precio', '$barrio', '$localidad',
'$estado', '$caracteristicas', '$comodidades', '$servicios', '$notas', '$consultas', '$conosca', '$plano', '$puntos', '$video', '$honorarios', '$agua', '$catastral', '$manzana', '$lotes', '$renta', '$muni', '$base', '$dominio', '$vendedor', '$domicilio', '$telefono', '$mail')"
;

        
$result=mysql_db_query($database,$query,$link);
        
        if(
mysql_affected_rows($link))
        { 
            echo 
"<html>
<head>

<title>Inmobiliaria Farran - Ingenieria</title>



<!--

#Layer89 {
    position:absolute;
    left:45px;
    top:205px;
    width:416px;
    height:35px;
    z-index:3;
}
-->
</style>

</head>"
;

echo
'

<div id="Layer89">
  <p>los datos se han cargado correctamente. </p>
  <p>
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="105" height="23">
      <param name="BGCOLOR" value="">
      <param name="movie" value="button22.swf">
      <param name="quality" value="high">
      <embed src="volver.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="105" height="23" ></embed>
    </object>
  </p>
</div>
<TABLE WIDTH=758 height="100%" BORDER=0 CELLPADDING=0 CELLSPACING=0 bordercolor="#FFFFFF" bgcolor="#FFFFFF">
    <TR>
        <TD height="123" colspan="2" bgcolor="#FFFFFF">&nbsp;</TD>
    </TR>
    <TR>
      <TD width="753" height="476" valign="top" bgcolor="#FFFFFF">
        <!-- start left navigation -->
      <!-- end left navigation --></TD>
      <TD width="5" valign="top" bordercolor="#FFFFFF" bgcolor="#FFFFFF"><pre>&nbsp;</pre></TD>
    </TR>
    
    
    <TR>
      <TD height="27" COLSPAN=2>&nbsp;</TD>
    </TR>
</TABLE>
</body>
</html>'

            
        } else 
        { 
            
            echo 
"
<html>
<head>

<title>Inmobiliaria Farran - Ingenieria</title>



<!--

#Layer89 {
    position:absolute;
    left:45px;
    top:205px;
    width:416px;
    height:35px;
    z-index:3;
}
-->
</style>

</head>"
;

echo
'

<div id="Layer89">
  <p>error al cargar los datos. </p>
  <p>
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="105" height="23">
      <param name="BGCOLOR" value="">
      <param name="movie" value="button22.swf">
      <param name="quality" value="high">
      <embed src="volver.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="105" height="23" ></embed>
    </object>
  </p>
</div>
<TABLE WIDTH=758 height="100%" BORDER=0 CELLPADDING=0 CELLSPACING=0 bordercolor="#FFFFFF" bgcolor="#FFFFFF">
    <TR>
        <TD height="123" colspan="2" bgcolor="#FFFFFF">&nbsp;</TD>
    </TR>
    <TR>
      <TD width="753" height="476" valign="top" bgcolor="#FFFFFF">
        <!-- start left navigation -->
      <!-- end left navigation --></TD>
      <TD width="5" valign="top" bordercolor="#FFFFFF" bgcolor="#FFFFFF"><pre>&nbsp;</pre></TD>
    </TR>
    
    
    <TR>
      <TD height="27" COLSPAN=2>&nbsp;</TD>
    </TR>
</TABLE>
</body>
</html>'


        } 
/* Cierre del else */ 




    
}
    else
    {   if(
$nombre_archivo !=''){
        echo 
"error al subir la foto";
   
    }
    }
}
?>
<?php 
include("conex.phtml"); 
   
$link=Conectarse(); 
   
$result=mysql_query("select * from propiedades where codigo='$codigo'",$link); 
?> 
<?php
    
    $caracteristicas
=str_replace("\r\n","\n",$caracteristicas);
    
$comodidades=str_replace("\r\n","\n",$comodidades);
     
$servicios=str_replace("\r\n","\n",$servicios);
      while(
$row mysql_fetch_array($result)) {
   
$direccion=$row["ubicacion"];
   if((
$row["categoria"]=='casadepto')||($row["codigo"]=='campos'))
   { 
$honorarios=(($row["precious"]*3)/100);
    }
   if(
$row["categoria"]=='lotes')
   { 
$honorarios=(($row["precious"]*5)/100);
    }
 }
  
mysql_free_result($result); 
   
mysql_close($link);


//ponemos el nivel de reporte de errores al máximo
error_reporting(E_ALL|E_STRICT);






// Functions for export to excel.
function xlsBOF($fp) {
  
fwrite($fppack("ssssss"0x8090x80x00x100x00x0));
  return;
}

function 
xlsEOF($fp) {
  
fwrite($fp,pack("ss"0x0A0x00));
  return;
}

function 
xlsWriteNumber($fp$Row$Col$Value) {
  
fwrite($fppack("sssss"0x20314$Row$Col0x0));
  
fwrite($fp,pack("d"$Value));
  return;
}

function 
xlsWriteLabel($fp$Row$Col$Value ) {
  
$L strlen($Value);
  
fwrite($fppack("ssssss"0x204$L$Row$Col0x0$L));
  
fwrite($fp$Value);
  return;
}

//creamos el archivo y mantenemos el puntero $fp apuntadolo
$fp=fopen('../imagenes/'.$codigo.'/datospublico.xls','w');

//pasamos el puntero a las funciones para escribir directamente al archivo
xlsBOF($fp);

/*
Make a top line on your excel sheet at line 1 (starting at 0).
The first number is the row number and the second number is the column, both are start at '0'
*/

xlsWriteLabel($fp0,0,"Datos de la propiedad.");

// Make column labels. (at line 3)
xlsWriteLabel($fp,2,0,"Codigo");
xlsWriteLabel($fp,2,1,"Dirección");
xlsWriteLabel($fp,2,2,"Operación");
xlsWriteLabel($fp,2,3,"Tipo");
xlsWriteLabel($fp,2,4,"Precio");
xlsWriteLabel($fp,2,5,"Barrio");
xlsWriteLabel($fp,2,6,"Localidad");
xlsWriteLabel($fp,2,7,"Estado");
xlsWriteLabel($fp,2,8,"Caracteristicas");
xlsWriteLabel($fp,2,9,"Comodidades");
xlsWriteLabel($fp,2,10,"Servicios");
xlsWriteLabel($fp,2,11,"Notas");
xlsWriteLabel($fp,2,13,"Honorarios");
xlsWriteLabel($fp,2,14,"Agua corriente");
xlsWriteLabel($fp,2,15,"Catastral");
xlsWriteLabel($fp,2,16,"Manzana");
xlsWriteLabel($fp,2,17,"Lotes");
xlsWriteLabel($fp,2,18,"Cta de rentas");
xlsWriteLabel($fp,2,19,"Cta. municipal");
xlsWriteLabel($fp,2,20,"Base imponible");
xlsWriteLabel($fp,2,21,"Dominio");
xlsWriteLabel($fp,2,22,"Vendedor");
xlsWriteLabel($fp,2,23,"Domicilio");
xlsWriteLabel($fp,2,24,"Tel");
xlsWriteLabel($fp,2,25,"Mail");

$xlsRow 3;

// Put data records from mysql by while loop.
xlsWriteNumber($fp,$xlsRow,0,$codigo);
xlsWriteLabel($fp,$xlsRow,1,$direccion);
xlsWriteLabel($fp,$xlsRow,2,$operacion);
xlsWriteLabel($fp,$xlsRow,3,$tipo);
xlsWriteLabel($fp,$xlsRow,4,$precio);
xlsWriteLabel($fp,$xlsRow,5,$barrio);
xlsWriteLabel($fp,$xlsRow,6,$localidad);
xlsWriteLabel($fp,$xlsRow,7,$estado);
xlsWriteLabel($fp,$xlsRow,8,$caracteristicas);
xlsWriteLabel($fp,$xlsRow,9,$comodidades);
xlsWriteLabel($fp,$xlsRow,10,$servicios);
xlsWriteLabel($fp,$xlsRow,11,$notas);


   
$xlsRow++;

xlsEOF($fp);
fclose($fp);
?>
  #2 (permalink)  
Antiguo 29/06/2010, 03:25
 
Fecha de Ingreso: enero-2007
Mensajes: 135
Antigüedad: 17 años, 3 meses
Puntos: 1
Respuesta: problema para cargar info en la bd

por las dudas les paso el html que llena el formulario.
Código 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>Inmobiliaria Farran -Software de Gestion</title>
<
style type="text/css">
<!--
.
<
body>
<
form name="form1" action="galeria.php" method="post"enctype="multipart/form-data">

<
table cellspacing="0" cellpadding="0" width="762"><!--DWLayoutTable-->
  
    <
tbody>
      <
tr>
        <
td width="7">&nbsp;</td>
        <
td valign="top" width="748" height="38"><table width="101%" cellpadding="0" cellspacing="0" bgcolor="#999999">
          <
tbody>
            <
tr>
              <
td 
                        height
="31" valign="center" bgcolor="#006699"><span class="Estilo20">&gt;
                <
label>Operacion                </label>
              </
span></td>
              </
tr>
            <
tr>
              <
td valign="center" bgcolor="#CCCCCC" height="31"><div align="center" class="txt-texto-negro Estilo26"><strong>c&oacute;digo <input name="codigo" type="Text" size="5"
              </
strong></div></td>
            </
tr>
          </
tbody>
        </
table></td>
        <
td width="10">&nbsp;</td>
      </
tr>
      <
tr>
        <
td rowspan="2">&nbsp;</td>
        <
td valign="center" align="left" bgcolor="#ffffff"><table cellspacing="0" cellpadding="0" width="100%" border="0">
          <
tbody>
            <
tr>
              <
td><table width="100%" 
border="0" cellpadding="0" cellspacing="5" bgcolor="#FFFFFF">
                <
tbody>
                  <
tr>
                 
                                
height="25" valign="top" 
                                
bordercolor="#d6d9da" class="Estilo5 Estilo4 Estilo2 txt-texto-11-bordo-B"><strong>Operaci&oacute;n</strong></td>
                          <
td height="25" valign="top" class="Estilo2 txt-texto-negro"><select name="operacion">
                  <
option value="Venta">Venta</option>
                  <
option value="Alquiler">Alquiler</option>
                  <
option value="Permuta">Permuta</option>
                </
select>&nbsp;</td>
                        </
tr>
                        <
tr bordercolor="#d6d9da">
                          <
td 
                                height
="39" valign="top" class="Estilo5 Estilo4 Estilo2 txt-texto-11-bordo-B"><strong>Tipo de Inmueble</strong></td>
                          <
td height="39" valign="top" 
                                
bordercolor="#d6d9da" class="Estilo5 Estilo4 Estilo2 txt-texto-negro"><input name="tipo" type="Text">
                          &
nbsp;</td>
                        </
tr>
                        <
tr bordercolor="#d6d9da">
                          <
td 
                                height
="48" valign="top" class="Estilo5 Estilo4 Estilo2 txt-texto-11-bordo-B"><strong>Precio</strong></td>
                          <
td height="48" valign="top" 
                                
bordercolor="#d6d9da" class="txt-texto-negro Estilo2"><span 
                          
                  
<tr bgcolor="#ffffff">
                    <
td colspan="2"><table cellspacing="0" cellpadding="0" width="100%" 
                              
border="0">
                      <
tbody>
                        <
tr>
                          <
td bgcolor="#006699" height="23"><span 
                                
class="txt-texto-11-bordo-B Estilo3 Estilo19"><span class="Estilo15">&nbsp;&gt;&nbsp;</span><span class="Estilo4"><span class="Estilo14">Notas</span></span></span></td>
                        </
tr>
                        <
tr>
                          <
td bgcolor="#e4edf2" height="20"><table width="100%" height="133" 
                                
border="0" cellpadding="0" cellspacing="5">
                            <
tbody>
                              <
tr>
                                <
td height="123"><p>
                                  <
textarea name="notas" cols="90" rows="4"></textarea>
                                  &
nbsp;</p></td>
                              </
tr>
                            </
tbody>
                          </
table></td>
                        </
tr>
                      </
tbody>
                    </
table></td>
                  </
tr>
                  
                  <
tr bgcolor="#ffffff">
                    <
td colspan="2"><table cellspacing="0" cellpadding="0" width="100%" 
                              
border="0">
                      <
tbody>
                        <
tr>
                          <
td bgcolor="#006699" height="23"><span 
                                
class="Estilo15 Estilo3 txt-texto-11-bordo-B Estilo19"><strong>&nbsp;&gt;&nbsp;Consultas 
                            sobre este Inmueble 
</strong></span></td>
                        </
tr>
                        <
tr>
                          <
td bgcolor="#e4edf2" height="20"><table cellspacing="5" cellpadding="0" width="100%" 
                                
border="0">
                            <
tbody>
                              <
tr>
                                <
td><input name="consultas" type="text" value="" size="90" />
                                  &
nbsp;</td>
                              </
tr>
                            </
tbody>
                          </
table></td>
                        </
tr>
                      </
tbody>
                    </
table></td>
                  </
tr>
                </
tbody>
              </
table></td>
            </
tr>
            <
tr>
              <
td><div align="center" class="Estilo24">
                <
p>Conozca mas acerca de esta propiedad
                  
<select name="conosca">
                      <
option value="No">No</option>
                      <
option value="si">S&iacute;</option>
                      
                    </
select>
</
p>
 <
p>Conozca  los puntos de interes
                  
<select name="puntos">
                      <
option value="No">No</option>
                      <
option value="si">S&iacute;</option>
                      
                    </
select>
</
p>
<
p>Conozca  la ubicaci&#243;n: 
                  
<select name="plano">
                      <
option value="No">No</option>
                      <
option value="si">S&iacute;</option>
                    </
select>
</
p>
<
p>Video
                  <
select name="video">
                      <
option value="No">No</option>
                      <
option value="si">S&iacute;</option>
                    </
select>
</
p>

                <
table width="438" border="1">
                  <
tr>
                    <
td>Agua Corriente 
                      <
label>
                      <
input name="agua" type="text" id="agua" value="" size="50" />
                      </
label></td>
                  </
tr>
                  <
tr>
                    <
td>Catastral
                      <
label>
                      <
input name="catastral" type="text" id="catastral" size="55" />
                      </
label></td>
                  </
tr>
                  <
tr>
                    <
td>Manzana
                      <
label>
                      <
input name="manzana" type="text" id="manzana" size="55" />
                      </
label></td>
                  </
tr>
                  <
tr>
                    <
td>Lote
                      <
label>
                      <
input name="lotes" type="text" id="lotes" size="63" />
                      </
label></td>
                  </
tr>
                  <
tr>
                    <
td>Ctade renta
                      <
label>
                      <
input name="renta" type="text" id="renta" size="53" />
                      </
label></td>
                  </
tr>
                  <
tr>
                    <
td>Ctamunicipal
                      <
label>
                      <
input name="muni" type="text" id="muni" size="51" />
                      </
label></td>
                  </
tr>
                 
                 
                   
                </
table>
                <
class="style1"><input name="grabar" type="submit" class="cajatexto1" value="Enviar Datos" style="font-weight: bold">&nbsp;
<
input type="reset" value="Cancelar" style="font-weight: bold">&nbsp;</p>
              </
div></td>
            </
tr>
          </
tbody>
        </
table></td>
        <
td 
      rowspan
="2"></td>
      </
tr>
    </
tbody>
  </
form>
</
table>
</
body>
</
html>
<
script language="javascript">
function 
muestra()
{
document.form1.imagen.src=document.form1.userfilevalue;
}
</script> 
el html esta acotado.. porque no entraba en el post
  #3 (permalink)  
Antiguo 29/06/2010, 03:27
 
Fecha de Ingreso: marzo-2010
Ubicación: Barcelona
Mensajes: 657
Antigüedad: 14 años, 1 mes
Puntos: 26
Respuesta: problema para cargar info en la bd

Mira a ver si es por el mysql_db_query, ya que esta funcion esta obsoleta.
Tambien al conectarte a la bd haz un mysql_select_db().

Prueba esto a ver si es por eso...
  #4 (permalink)  
Antiguo 29/06/2010, 03:50
 
Fecha de Ingreso: enero-2007
Mensajes: 135
Antigüedad: 17 años, 3 meses
Puntos: 1
Respuesta: problema para cargar info en la bd

como andas?
muchas gracias por responder..
pruebo lo que me comentaste..
y me dice:
Código PHP:
WarningWrong parameter count for mysql_select_db() in /home/inmobili/public_html/software/galeria.php on line 60
error al cargar los datos

y el codigo del error es
Código PHP:
$link=mysql_connect($server,$dbuser,$dbpass);
                        
        
$query"INSERT INTO galeria (codigo, Foto, Operación, tipo, precio, barrio, localidad,
estado, caracteristicas, comodidades, servicios, notas, consultas, conosca, plano, puntos, video, honorarios, agua, catastral, manzana, lotes, renta, muni, base, dominio, vendedor, domicilio, telefono, mail) 

VALUES ('$codigo', '$ruta', '$operacion', '$tipo', '$precio', '$barrio', '$localidad',
'$estado', '$caracteristicas', '$comodidades', '$servicios', '$notas', '$consultas', '$conosca', '$plano', '$puntos', '$video', '$honorarios', '$agua', '$catastral', '$manzana', '$lotes', '$renta', '$muni', '$base', '$dominio', '$vendedor', '$domicilio', '$telefono', '$mail')"
;

        [
B]$result=mysql_select_db($database,$query,$link);[/B
te pido mil disculpas.. por seguir repreguntando..
te juro que no lo veo al error..
gracias
  #5 (permalink)  
Antiguo 29/06/2010, 03:59
 
Fecha de Ingreso: enero-2007
Mensajes: 135
Antigüedad: 17 años, 3 meses
Puntos: 1
Respuesta: problema para cargar info en la bd

me parece por lo que entendi leyendo que tenia que hacer
Código PHP:
[B]$result=mysql_select_db($database);[/B
ya no me da error, pero sigo igual que antes..
  #6 (permalink)  
Antiguo 29/06/2010, 05:59
 
Fecha de Ingreso: marzo-2010
Ubicación: Barcelona
Mensajes: 657
Antigüedad: 14 años, 1 mes
Puntos: 26
Respuesta: problema para cargar info en la bd

tambien pusistes el mysql_query? me fije que en un lado lo utilizabas pero al principio utilizabas el mysql_db_query(), aun asi intento mirar todo el codigo y ya te dire algo si encuentro algo mas.

Etiquetas: bd, info
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:55.