Ver Mensaje Individual
  #11 (permalink)  
Antiguo 11/11/2010, 07:44
rafaxusirati
 
Fecha de Ingreso: julio-2010
Ubicación: Cerca Sitges (Barcelona)
Mensajes: 98
Antigüedad: 13 años, 9 meses
Puntos: 4
Respuesta: php para consultas

Me muestra la página ok, pero en la parte superior de la pantalla me aparece:

SELECT ciudad, tituloanuncio, descripcionanuncio FROM contactos WHERE ciudad LIKE CONCAT('%', TRIM(IF(LENGTH(TRIM('')) > 0, '', ciudad)), '%') AND tituloanuncio LIKE CONCAT('%', TRIM(IF(LENGTH(TRIM('')) > 0, '', tituloanuncio)), '%') AND descripcionanuncio LIKE CONCAT('%', TRIM(IF(LENGTH(TRIM('')) > 0, '', descripcionanuncio)), '%')

con el código:
Código PHP:
Ver original
  1. <?php require_once('Connections/contactos.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6.   if (PHP_VERSION < 6) {
  7.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8.   }
  9.  
  10.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  11.  
  12.   switch ($theType) {
  13.     case "text":
  14.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  15.       break;    
  16.     case "long":
  17.     case "int":
  18.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  19.       break;
  20.     case "double":
  21.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  22.       break;
  23.     case "date":
  24.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  25.       break;
  26.     case "defined":
  27.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  28.       break;
  29.   }
  30.   return $theValue;
  31. }
  32. }
  33.  
  34. mysql_select_db($database_contactos, $contactos);
  35. $query_Recordset1 = "SELECT ciudad, tituloanuncio, descripcionanuncio FROM contactos WHERE ciudad LIKE CONCAT('%', TRIM(IF(LENGTH(TRIM('$ciud')) > 0, '$ciud', ciudad)), '%') AND tituloanuncio LIKE CONCAT('%', TRIM(IF(LENGTH(TRIM('$titul')) > 0, '$titul', tituloanuncio)), '%') AND descripcionanuncio LIKE CONCAT('%', TRIM(IF(LENGTH(TRIM('$descr')) > 0, '$descr', descripcionanuncio)), '%')  ";
  36. echo $query_Recordset1; //para ver consulta por pantalla
  37. $Recordset1 = mysql_query($query_Recordset1, $contactos) or die(mysql_error());
  38. $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  39. $totalRows_Recordset1 = mysql_num_rows($Recordset1);
  40. ?>