By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,722 Members | 1,874 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,722 IT Pros & Developers. It's quick & easy.

Problem with date

nomad
Expert 100+
P: 664
I working on a site for a client where they want a calendar to display all their events that they are planning to have. I have built the calendar but I'm having problems with the event part where chose either am or pm.
If I chose pm and hit the select button then view the calendar it say am.
For the db I have event_am varchar(2) should I use emum instead?


Can someone please help me

thanks
nomad
PS if you need the calendar section please let me know.

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\Program Files\xampp\htdocs\23\event.php on line 12// note it will be line 7

here is the code:
[PHP]
<body>
<h1>Show/Add Events</h1>
<?php
$conn = mysql_connect("localhost", "abc", "abc") or die(mysql_error());
mysql_select_db("testDB",$conn) or die(mysql_error());

//add any new event
if ($_POST[op] == "do") {
$event_date = $_POST[y]."-".$_POST[m]."-".$_POST[d]." ".$_POST[event_time_hh].":".$_POST[event_time_mm].":00" .$_POST[event_am]." ";

$insEvent = "INSERT INTO calendar_events VALUES('', '$_POST[event_title]', '$_POST[event_shortdesc]', '$event_date', 'event_am')";
@mysql_query($insEvent) or die(mysql_error());

}

//show events for this day
$getEvent = "SELECT event_title, event_shortdesc, date_format(event_start, '%l:%i %p') as fmt_date FROM calendar_events WHERE month(event_start) = '$_GET[m]' AND dayofmonth(event_start) = '$_GET[d]' AND year(event_start) = '$_GET[y]' ORDER BY event_start";

$getEvent_res = @mysql_query($getEvent) or die(mysql_error());

if (@mysql_num_rows($getEvent_res) > 0) {
while ($ev = @mysql_fetch_array($getEvent_res)) {
$event_title = stripslashes($ev['event_title']);
$event_shortdesc = stripslashes($ev['event_shortdesc']);
$fmt_date = $ev['fmt_date'];

$event_txt .= "<P><strong>$fmt_date</strong>: $event_title<br>$event_shortdesc";

}

}

if ($event_txt != "") {
echo "<P><strong>Today's Events:</strong>
$event_txt
<hr noshade width=80%>";
}

// show form for adding an event
echo "<form method=post action=\"$_SERVER[PHP_SELF]\">
<P><strong>Would you like to add an event?</strong><br>Complete the form below and press the submit button to add the event and refresh this window.</p>
<p><strong>Event Title:</strong><br>
<input type=text name=event_title size=25 maxlength=25>
<p><strong>Event Description:</strong><br>
<input type=text name=event_shortdesc size=25 maxlength=255>
<p><strong>Event Time (hh:mm):</strong><br>

<select name=event_time_hh>";
for ($x=1; $x <= 12; $x++) {
echo "<option value=\"$x\">$x</option>";
}
echo "</select> :

<select name=event_time_mm>
<option value=\"00\">00</option>
<option value=\"15\">15</option>
<option value=\"30\">30</option>
<option value=\"45\">45</option>
</select>

<select name=event_am>
<option value=\"am\">am</option>
<option value=\"pm\">pm</option>
</select>

<input type=hidden name=m value=$_GET[m]>
<input type=hidden name=d value=$_GET[d]>
<input type=hidden name=y value=$_GET[y]>
<input type=hidden name=op value=do>
<br><br>
<input type=submit name=submit value=\"Add Event\">
</form>";
?>

[/PHP]
Sep 12 '08 #1
Share this Question
Share on Google+
1 Reply


nomad
Expert 100+
P: 664
Never mind folks I figure it out.
I used timedate and based it on a 24 hour period.
got rid of the event_am field as well.

nomad
Sep 12 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.