Forum Moderators: coopster

Message Too Old, No Replies

script works on my pc but not on server

         

helenp

8:32 pm on Nov 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi this is very very strange.
On my pc I have the same mysql version as my host,
the php on my pc has globals on and on the server off.

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.........

Birdman

8:38 pm on Nov 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The first thing to do when trouble shooting is to print(echo) your sql to the page to verify that the inserted PHP variables actually contain the data it should.

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!"; }

helenp

11:06 pm on Nov 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



thanks,
I am still in the same,
I changed it to your code, and got
the same result on my pc as on my server,
so everything is all right, but don´t work on 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!

helenp

11:39 pm on Nov 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



My host that is gurys with mysql php just had an look and can´t see anything wrong.....what can it be?

helenp

10:09 am on Nov 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi again,
this is just crazy,
doing debugging leaving only this short code in the page:
$sql = "SELECT llegada, salida, propiedad from bookings where ( propiedad = '$propiedad' )";
$rows = mysql_fetch_assoc(mysql_query($sql));
if ($salida==$rows['llegada'])
{ echo "should show up"; }
else { echo "shows up"; }

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 ;

helenp

11:23 am on Nov 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Finally I discovered that there is nothing wrong in the db,
the problem is that the code only works if there is only one entry for the property,....
so the problem is in the code.

Now it works, changing the code to this:
$sql = "SELECT llegada, salida, propiedad from bookings where ( propiedad = '$propiedad' ) AND ((llegada = '$salida') OR (salida = '$llegada'))";