- Home
- Categorie
- Coding e Sistemistica
- Coding
- mysql + comparazioni ... aiuto grazie
- 
							
							
							
							
							
mysql + comparazioni ... aiuto grazie[html] 
 $sqlR = mysql_query("select lu1, lu2, lu3,l4 from dat where
 (lu1 < '$idora' and lu2 >'$idora')
 or
 (lu3 < '$idora' and lu4 >'$idora')");
 [/html]Salve, qualcuno saprebbe dirmi perchè mi da errore e se c'è una forma corretta per scrivere quello che ho inteso sopra ... ?grazie... 
 
- 
							
							
							
							
							Ciao robert_13_, 
 prova a concatenare le stringhe così:[php] 
 $qry = "select lu1, lu2, lu3,l4 from dat where "
 . "(lu1 < '" . $idora . "' and lu2 >'" . $idora . "') "
 . "or (lu3 < '" . $idora . "' and lu4 >'" . $idora . "')";$res = mysql_query($qry); 
 [/php]Ciao
 
- 
							
							
							
							
							
Qual è l'errore? E cosa c'è in "$idora"? 
 
- 
							
							
							
							
							
Grazie così sembra andare : [HTML] 
 $sql1 = mysql_query("select * from dat where(lu1 <= '".$idora."' and lu2 >='".$idora."') or (lu3 <= '".$idora."' and lu4 >='".$idora."')")or die ("Errore: ". mysql_error());
 [/HTML]Sto estraendo stringhe comprese tra 2+2 record numerici "orario".  L'errore era che non c'era l'errore e neanche dati restituiti e non riuscivo a capire . L'errore era che non c'era l'errore e neanche dati restituiti e non riuscivo a capire . 
 
- 
							
							
							
							
							
Come tip posso suggerirti di aggiungere sempre un or die(mysql_error()) alla fine di una query cosi in caso di errore hai qualche indizio.