Ver Mensaje Individual
  #2 (permalink)  
Antiguo 30/12/2011, 08:38
chumy_
 
Fecha de Ingreso: noviembre-2011
Mensajes: 121
Antigüedad: 15 años
Puntos: 0
Respuesta: problema al buscar con select

y este es el codigo de la pagina que hace la "busqueda"

Código PHP:
<?php require_once('Connections/localhost.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (
PHP_VERSION < 6) {
    
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}

$currentPage = $_SERVER["PHP_SELF"];

$maxRows_seleccionados = 15;
$pageNum_seleccionados = 0;
if (isset(
$_GET['pageNum_seleccionados'])) {
  
$pageNum_seleccionados = $_GET['pageNum_seleccionados'];
}
$startRow_seleccionados = $pageNum_seleccionados * $maxRows_seleccionados;

$colname_seleccionados = "-1";
if (isset(
$_GET['cod_proy'])) {
  
$colname_seleccionados = $_GET['cod_proy'];
}
mysql_select_db($database_localhost, $localhost);
$query_seleccionados = sprintf("SELECT ncert, Fecha, proyecto, cod_proy, poblacion, calle, n, tipo_recinto, n1 FROM cert WHERE cod_proy = %s", GetSQLValueString($colname_seleccionados, "text"));
$query_limit_seleccionados = sprintf("%s LIMIT %d, %d", $query_seleccionados, $startRow_seleccionados, $maxRows_seleccionados);
$seleccionados = mysql_query($query_limit_seleccionados, $localhost) or die(mysql_error());
$row_seleccionados = mysql_fetch_assoc($seleccionados);

if (isset(
$_GET['totalRows_seleccionados'])) {
  
$totalRows_seleccionados = $_GET['totalRows_seleccionados'];
} else {
  
$all_seleccionados = mysql_query($query_seleccionados);
  
$totalRows_seleccionados = mysql_num_rows($all_seleccionados);
}
$totalPages_seleccionados = ceil($totalRows_seleccionados/$maxRows_seleccionados)-1;

$queryString_seleccionados = "";
if (!empty(
$_SERVER['QUERY_STRING'])) {
  
$params = explode("&", $_SERVER['QUERY_STRING']);
  
$newParams = array();
  foreach (
$params as $param) {
    if (
stristr($param, "pageNum_seleccionados") == false && 
        
stristr($param, "totalRows_seleccionados") == false) {
      
array_push($newParams, $param);
    }
  }
  if (
count($newParams) != 0) {
    
$queryString_seleccionados = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_seleccionados = sprintf("&totalRows_seleccionados=%d%s", $totalRows_seleccionados, $queryString_seleccionados);
?>
<!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>Documento sin título</title>
<style type="text/css">
body,td,th {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
}
</style>
</head>

<body>
<table width="950" border="0">
  <tr valign="middle">
    <td width="57"><?php if ($pageNum_seleccionados > 0) { // Show if not first page ?>
      <a href="<?php printf("%s?pageNum_seleccionados=%d%s", $currentPage, 0, $queryString_seleccionados); ?>"><img src="imagenes/First.gif" alt="" /></a>
      <?php } // Show if not first page ?></td>
    <td width="406"><?php if ($pageNum_seleccionados > 0) { // Show if not first page ?>
      <a href="<?php printf("%s?pageNum_seleccionados=%d%s", $currentPage, max(0, $pageNum_seleccionados - 1), $queryString_seleccionados); ?>"><img src="imagenes/Previous.gif" alt="" /></a>
      <?php } // Show if not first page ?></td>
    <td width="401" align="right"><?php if ($pageNum_seleccionados < $totalPages_seleccionados) { // Show if not last page ?>
      <a href="<?php printf("%s?pageNum_seleccionados=%d%s", $currentPage, min($totalPages_seleccionados, $pageNum_seleccionados + 1), $queryString_seleccionados); ?>"><img src="imagenes/Next.gif" alt="" /></a>
      <?php } // Show if not last page ?></td>
    <td width="68" align="right"><?php if ($pageNum_seleccionados < $totalPages_seleccionados) { // Show if not last page ?>
      <a href="<?php printf("%s?pageNum_seleccionados=%d%s", $currentPage, $totalPages_seleccionados, $queryString_seleccionados); ?>"><img src="imagenes/Last.gif" alt="" /></a>
      <?php } // Show if not last page ?></td>
  </tr>
</table>
<table width="950" border="0" align="center">
  <tr>
    <td align="center"><strong>N&deg;</strong></td>
    <td align="center"><strong>FECHA</strong></td>
    <td align="center"><strong>PROYECTO</strong></td>
    <td align="center"><strong>DIRECCION</strong></td>
    <td align="center"><p>MODIFICACI&Oacute;N</p></td>
    <td align="center">VALIDAR</td>
  </tr>
  <?php do { ?>
    <tr>
      <td align="center"><?php echo $row_seleccionados['ncert']; ?></td>
      <td align="center"><?php echo $row_seleccionados['Fecha']; ?></td>
      <td><?php echo $row_seleccionados['proyecto']; ?></td>
      <td><?php echo $row_seleccionados['poblacion']; ?> <?php echo $row_seleccionados['calle']; ?> <?php echo $row_seleccionados['n']; ?> <?php echo $row_seleccionados['tipo_recinto']; ?> <?php echo $row_seleccionados['n1']; ?></td>
      <td align="center"><form id="form1" name="form1" method="post" action="">
        <input type="submit" name="validacion" id="validacion" value="Modificar" />
      </form></td>
      <td align="center"><form id="form2" name="form2" method="post" action="">
        <input type="submit" name="validar" id="validar" value="Validar" />
      </form></td>
    </tr>
    <?php } while ($row_seleccionados = mysql_fetch_assoc($seleccionados)); ?>
</table>
<table width="950" border="0">
  <tr valign="middle">
    <td width="57"><?php if ($pageNum_seleccionados > 0) { // Show if not first page ?>
        <a href="<?php printf("%s?pageNum_seleccionados=%d%s", $currentPage, 0, $queryString_seleccionados); ?>"><img src="imagenes/First.gif" /></a>
        <?php } // Show if not first page ?></td>
    <td width="406"><?php if ($pageNum_seleccionados > 0) { // Show if not first page ?>
        <a href="<?php printf("%s?pageNum_seleccionados=%d%s", $currentPage, max(0, $pageNum_seleccionados - 1), $queryString_seleccionados); ?>"><img src="imagenes/Previous.gif" /></a>
        <?php } // Show if not first page ?></td>
    <td width="401" align="right"><?php if ($pageNum_seleccionados < $totalPages_seleccionados) { // Show if not last page ?>
        <a href="<?php printf("%s?pageNum_seleccionados=%d%s", $currentPage, min($totalPages_seleccionados, $pageNum_seleccionados + 1), $queryString_seleccionados); ?>"><img src="imagenes/Next.gif" /></a>
        <?php } // Show if not last page ?></td>
    <td width="68" align="right"><?php if ($pageNum_seleccionados < $totalPages_seleccionados) { // Show if not last page ?>
        <a href="<?php printf("%s?pageNum_seleccionados=%d%s", $currentPage, $totalPages_seleccionados, $queryString_seleccionados); ?>"><img src="imagenes/Last.gif" /></a>
        <?php } // Show if not last page ?></td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result
($seleccionados);
?>
donde esta el p*** error?