Forum Moderators: coopster
Below code (cut) works on my pc, but on the server, only the else is displayed.....dont bother at all about the if, and elseif....
First I have an query:
$result = mysql_query ("SELECT etc. if ($row = mysql_fetch_array($result)){ etc.
then this to finish:
} while ($row = mysql_fetch_array($result));
echo "ˇ Not available!";
echo "</table> \n";
}
and after this the else comes,
and in the else I have another query, and here is where the problem is, only the echo in the else code below is displayed on the server but on my pc, checks and displays the echo depending on the if and elseif:
else {
$sql = "SELECT llegada, salida, propiedad from bookings where ( propiedad = '$propiedad' )";
$rows = mysql_fetch_assoc(mysql_query($sql));
if ($salida==$rows['llegada'])
{ echo "ˇ text here!"; }
elseif ($llegada==$rows['salida'] && $salida==$rows['llegada'])
{ echo "ˇ another text here!"; }
elseif ($llegada==$rows['salida'])
{ echo "ˇ another text here!"; }
else { echo "ˇthis text is always displayed on my server!"; }
Just can´t understand.........
Another trouble shooting method is to add an or die(mysql_error()).
else {
$sql = "SELECT llegada, salida, propiedad from bookings where ( propiedad = '$propiedad' )";
print $sql;
$result = mysql_query($sql) or die(mysql_error());
$rows = mysql_fetch_assoc($result) ;
if ($salida==$rows['llegada'])
{ echo "ˇ text here!"; }
elseif ($llegada==$rows['salida'] && $salida==$rows['llegada'])
{ echo "ˇ another text here!"; }
elseif ($llegada==$rows['salida'])
{ echo "ˇ another text here!"; }
else { echo "ˇthis text is always displayed on my server!"; }
result on both:
SELECT llegada, salida, propiedad from bookings where ( propiedad = 'Casa_Blanca_5' )ˇ Casa_Blanca_5 está disponible desde 2004-12-15 hasta 2005-01-10!
I got the same result, worked on my local db, but didn´t on the server.
So I exported the table from the server to my local to have them identical, and now it don´t work on my local either..... so something is wrong in the db, but what, I thought they were configured just the same.
This is my table:
CREATE TABLE `bookings` (
`id` smallint(6) NOT NULL auto_increment,
`llegada` date NOT NULL default '0000-00-00',
`tipo` varchar(11) NOT NULL default '',
`tiporeserva` varchar(11) NOT NULL default '',
`salida` date NOT NULL default '0000-00-00',
`tipo_sal` varchar(10) NOT NULL default '',
`hora_llegada` varchar(10) default NULL,
`hora_salida` varchar(10) default NULL,
`propiedad` varchar(30) NOT NULL default '',
`cliente` varchar(30) NOT NULL default '',
`reservado` date NOT NULL default '0000-00-00',
`transporte` varchar(10) default NULL,
`comentarios` varchar(100) default NULL,
`llegada_por` varchar(15) default NULL,
`salida_por` varchar(15) default NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=64 ;
Now it works, changing the code to this:
$sql = "SELECT llegada, salida, propiedad from bookings where ( propiedad = '$propiedad' ) AND ((llegada = '$salida') OR (salida = '$llegada'))";