Sign in to follow this  

[web] PHP+mysql problem

This topic is 4836 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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:
$dayDate = date("Y") . "-" . $currentMonth . "-" . $day2;
        $row = mysql_fetch_array($result)
        if($row['Date'] == $dayDate) {
          echo($row["EventText"]);
        }

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.

Share this post


Link to post
Share on other sites
Quote:
Original post by Charles Hwang
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?


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


Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

This topic is 4836 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this