Ver Mensaje Individual
  #14 (permalink)  
Antiguo 21/09/2011, 05:34
emeotero
 
Fecha de Ingreso: mayo-2011
Ubicación: Santiago de Compostela
Mensajes: 126
Antigüedad: 13 años
Puntos: 0
Respuesta: php y javascript forms

aaarg, pensaba q estaba pero no!. estoy obteniendo los valores de los inputs y los meto en un string separado por # y ' para despues procesarlo:

Código HTML:
var txt='';
	var i;
	var count = 0;
	for (i=0; i<probachooser.options.length; i++) {
	    if (probachooser.options[i].selected) {
	      if (count==0)
		txt+= ""+probachooser.options[i].value+"'";
	      else
	     txt+= "#'"+probachooser.options[i].value+"'";
	    }
	count++;
	}
    url_proba='date1='+proba_date1+'&date2='+proba_date2+'&especies='+txt;
	xhr(url_proba);
el post envia, por ejemplo esta consulta tipo:

date1 20110905
date2 20110914
especies #'ALC'#'PHO'#'SWX'#'OUM'

Fuente
date1=20110905&date2=20110914&especies=#'ALC'#'PHO '#'SWX'#'OUM'


lo quiero recoger en PHP y sustituir la almohadilla por comas y hacer la consulta (de momento no he pasado a lo de las fechas)

Código PHP:
$especies_procesar str_replace("#",",",$_POST['especies']);
$query 'select id_haul, id_catch, shooting_time ST_AsGeoJSON(geom, 4) AS geojson from "haul" natural inner join catch where a_code in ('.$especies_procesar.') and shooting_time between \'-infinity\' and \'now\'';
echo 
$query
y lo q me sale es:

select id_haul, id_catch, shooting_time ST_AsGeoJSON(geom, 4) AS geojson from "haul" natural inner join catch where a_code in (,'ALC','PHO','SWX','OUM') and shooting_time between '-infinity' and 'now'
Warning: pg_query(): Query failed: ERROR: syntax error at or near "(" at character 53 in /var/www/html/faros/Geo/consulta2.php on line 24
Query failed: ERROR: syntax error at or near "(" at character 53


como quito ese primer caracter? (q supongo q es el problema)