Forum Moderators: coopster

Message Too Old, No Replies

eliminate error message

         

helenp

7:18 pm on Jan 13, 2006 (gmt 0)

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



Hi,
I have an searcher and if the people put the dates in the wrong way, I have an error message displayed,
and of course though the select ever been done also php's error message is displayed and it is very ugly,
is there a way not to show the warning message?

My message: something is wrong in the dates you chosen arrival: 2006-02-01 and departure: 2006-01-01
please search again

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/user/public_html/page.php on line 183

jatar_k

7:24 pm on Jan 13, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



compare the dates on submit and if the first is after the second then inform them nicely instead of letting it get to the query

helenp

7:38 pm on Jan 13, 2006 (gmt 0)

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



My kind message displays alright,
but the mysql message comes below,
and I donīt think it should though on top of the code I have the if date thing:
if ($salida > $llegada or $sinfecha=="nodates"){
then rest of if.s and the selects
and finally my else error:

else {echo "something is wrong in the dates you chosen arrival: $llegada and departure: $salida <br>please search again<br>";}
if ($row = mysql_fetch_array($result)){
if ($sinfecha!="nodates"){
echo "<p>Properties found available from $llegada to $salida</p>";}
echo "<table class='tabla' border='0'> \n";
do {
$row["id_propiedad"] = str_replace("_", " ", $row["id_propiedad"]);

So the problems is where it is situaded, but I see it correct.

jatar_k

7:48 pm on Jan 13, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



ah

if ($row = mysql_fetch_array($result)){
if ($sinfecha!="nodates"){

those should be reversed, like so

if ($sinfecha!="nodates"){
if ($row = mysql_fetch_array($result)){

if there are 'nodates' then you don't want the mysql_fetch_array to fire, which is probably where the error is from

helenp

8:01 pm on Jan 13, 2006 (gmt 0)

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



No,
actually they can select an radiobutton if they donīt have any actual dates, and then yes I want the mysql select to show up, so if the radiobutton is selected I want it,
and if the radiobutton is not selected and they put in the dates correctly also I want it,
I donīt want it only if the departure date is lower than the arrival dates.
Hope I explained myself.

It is for properties not for flights, often people search but donīt know or care the dates.

This message I put up, just to state the dates they chosed in the result page.
if ($sinfecha!="nodates"){
echo "<p>Properties found available from $llegada to $salida</p>";}

helenp

9:28 pm on Jan 13, 2006 (gmt 0)

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



I think the problem is that the form is on another page so there is no if ($_POST['send']) {: on the page,
normally the if statement and else should be inside the if post statement.

helenp

10:01 am on Jan 14, 2006 (gmt 0)

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



I found the error
this:
else {echo "<p>something is wrong in the dates you chosen arrival: $llegada and departure: $salida <br>please search again<br></p>";}
should be at the end, after: if ($row = mysql_fetch_array($result)){