Jump to content

parsing problem


era

Recommended Posts

Hello,

 

I'm having a problem telling if the current date matches a date in my true_date field. It seems so basic and I've never got it to work correctly.  Basically, in the $true_date field there is a 4 digit value for the first day of racing, like today - "0226".  $today below returns the correct value.  I just want the logic to be "if there's todays date($today) in the $true_date field, show the row_array, else just throw up the no-racing.gif image".

 

This seems so obvious to me.  Should this work? If it's TRUE, it shows no problem, if it's FALSE, and the $true_date field is empty(none are empty actually, it';s just that both are not equal), then it fails to complete the function.

 

Thanks,

 

E

 

<?php

 

$sql = mysql_query("...");

 

$today = date("md");

 

while($row = mysql_fetch_array($sql)) {

 

if ($true_date == $today) {

$row_array[] = <img src=\"/images/flags/$row[co_code].png\" style=\"margin: 0px 7px 0px 7px; color: #990000;\" border=\"0\" alt=\"$row[co_code]\" />";

$random_row = $row_array[rand(0, count($row_array) - 1)];

} else {

$random_row = <img src=\"/images/rtw/no-racing.gif\" alt=\"$row[se_val]\" title=\"$row[se_def]\" style=\"margin: 0px;\" border=\"0\" />";

}

}

 

echo $random_row;

 

?>

Link to comment
https://forums.phpfreaks.com/topic/40774-parsing-problem/
Share on other sites

You're missing quotes around the strings. Try:

<?php
$sql = mysql_query("...");
$today = date("md");
while($row = mysql_fetch_array($sql)) {
       if ($true_date == $today) {
               $row_array[] = '<img src="/images/flags/' . $row['co_code'] . '.png" style="margin: 0px 7px 0px 7px; color: #990000;" border="0" alt="' . $row['co_code'] . '" />';
               $random_row = $row_array[rand(0, count($row_array) - 1)];
       } else {
               $random_row = '<img src="/images/rtw/no-racing.gif" alt="' . $row['se_val']" title="$row[se_def]" style="margin: 0px;" border="0" />';
       }
}
echo $random_row;
?>

 

Ken

Link to comment
https://forums.phpfreaks.com/topic/40774-parsing-problem/#findComment-197400
Share on other sites

Thanks Ken.  That was a typo unfortunately.

 

It works great, until there's no racing for that date.  If there's no racing(lets say today is 0301 and there's no record with 0301 in the true_date field), I'd like it to simply go to the no-racing.gif.  Instead, it refuses to perform the function for some reason.  So instead of a broken image for no-racing.gif, it doesn't try to load anything.

 

Thanks again.

 

E

Link to comment
https://forums.phpfreaks.com/topic/40774-parsing-problem/#findComment-197420
Share on other sites

That's what's freaky; no error, no html, nothing.  no characters of any kind.  I'm convinced that I'm just not asking for the right thing in my logic.  How do I say "if no date in the true_date field that matches THE DATE TODAY(ie. 0301 for March 1st) do this other thing - show this image or whatever".

 

If todays date is in the database it shows random data and all is cool.  If there's no date for today in the db it's as if it fails to complete the function.  I know it has to be something simple.  ;] - Like I'm overlooking something.

 

Thanks again.

 

E

 

Link to comment
https://forums.phpfreaks.com/topic/40774-parsing-problem/#findComment-197440
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.