$dayDate = date("Y") . "-" . $currentMonth . "-" . $day2;
$row = mysql_fetch_array($result)
if($row['Date'] == $dayDate) {
echo($row["EventText"]);
}
[web] PHP+mysql problem
I'm making a calendar where each day has an event. So when I get data out of the database, I need to make sure it belongs on THAT day. So I tried this:
But that returns this error: Parse error: parse error, unexpected T_IF in /home/xb4a1aa/public_html/calendarj.php on line 178
Anyone know whats wrong, or how to accomplish the logic above? the Date field is Date data type as well.
The '$row = mysql_fetch_array($result)' line lacks a semicolon, if you add one in the error should go away.
Also;
$row = mysql_fetch_array($result);
should be replaced with
$row = mysql_fetch_assoc($result);
$row = mysql_fetch_array($result);
should be replaced with
$row = mysql_fetch_assoc($result);
Quote:Original post by benryves
Also;
$row = mysql_fetch_array($result);
should be replaced with
$row = mysql_fetch_assoc($result);
Why assoc...? Doesn't that yeild field[1]; integer identifiers?
Quote:Original post by Charles HwangQuote:Original post by benryves
Also;
$row = mysql_fetch_array($result);
should be replaced with
$row = mysql_fetch_assoc($result);
Why assoc...? Doesn't that yeild field[1]; integer identifiers?
Nope... you get the field names. You only get the field names.
Quote:PHP Manual
mysql_fetch_assoc() is equivalent to calling mysql_fetch_array() with MYSQL_ASSOC for the optional second parameter. It only returns an associative array. This is the way mysql_fetch_array() originally worked. If you need the numeric indices as well as the associative, use mysql_fetch_array().
Ah I see I learned something today. So assoc essentially lessens time for the query/work rather than retrieving both numberical and literal and being a tad bit slower (not really an issue these days however).
Quote:Original post by benryves
Also;
$row = mysql_fetch_array($result);
should be replaced with
$row = mysql_fetch_assoc($result);
Or: $row = mysql_fetch_array($result, MYSQL_ASSOC);
This will only return an associative array, the same as mysql_fetch_assoc.
[Edited by - Maquiavel on September 14, 2004 10:42:22 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement