problemer med min kalender.
Hej alle sammen. Er der en klog person der kan fortælle mig hvorfor den ikke vil sætte en dato ind i min database? Jeg har fornyligt konventeret min db fra access til MySql, og samtidig flyttet til b-one....----------------------------------------------------------------
<%
sub calenderadmin
restricted()
if getmode() = "insert" then
if request.form("mode") = "insert" then
err = 0
startdate = request.form("startday") & "-" & request.form("startmonth") & "-" & request.form("startyear") & " " & request.form("starthours") & ":" & request.form("startmin")
enddate = request.form("endday") & "-" & request.form("endmonth") & "-" & request.form("endyear") & " " & request.form("endhours") & ":" & request.form("endmin")
if len(enddate) < 14 then enddate = startdate
eventname = replace(request.form("eventname"),"'","''")
location = replace(request.form("location"),"'","''")
capacity = request.form("capacity")
price = request.form("price")
website = request.form("website")
eventdescription = replace(request.form("eventdescription"),"'","''")
eventdescription = replace(eventdescription,vbcrlf,"<br>")
if len(startdate) < 14 then
response.write(len(startdate) & " / " & startdate)
err = 1
errormsg = "<br>Feltet 'Start' er ikke udfyldt korrekt"
end if
if eventname = "" then
err = 1
errormsg = errormsg + "<br>Du skal skrive et navn"
end if
if location = "" then
err = 1
errormsg = errormsg + "<br>Du skal angive et sted"
end if
if not capacity = "" then
if isnumeric(capacity) = 2 then
err = 1
errormsg = errormsg + "<br>Feltet 'Pladser' må kun indeholde tal"
end if
end if
if not price = "" then
if isnumeric(price) = 2 then
err = 1
errormsg = errormsg + "<br>Feltet 'Pris' må kun indeholde tal"
end if
end if
if not website = "" then
if instr(website,"http://") = 1 or instr(website,".") = 0 then
err = 1
errormsg = errormsg + "<br>Feltet 'Website' er ikke udfyldt korrekt"
end if
end if
if eventdescription = "" then
err = 1
errormsg = errormsg + "<br>Du skal skrive en beskrivelse"
end if
if err = 1 then errormsg = errormsg + "<br>"
if err = 0 then
SQL = "INSERT INTO calender(startdate, enddate, eventname, location, price, capacity, website, description) VALUES('"
SQL = SQL & startdate & "','"
SQL = SQL & enddate & "','"
SQL = SQL & eventname & "','"
SQL = SQL & location & "','"
SQL = SQL & price & "','"
SQL = SQL & capacity & "','"
SQL = SQL & website & "','"
SQL = SQL & eventdescription & "')"
set RS = conn.execute(SQL)
'response.write(SQL)
noerror = "<br>Arrangementet blev gemt i databasen<br>"
end if
end if
%>
<form name="form1" method="post" action="default.asp?page=<%= getpage() %>&mode=insert"><input type='hidden' name='mode' value='insert'>
<table width="540" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td colspan="2">Alle felter markeret med * skal udfyldes</td>
</tr>
<tr>
<td colspan="2"><font color="#990000"><%= errormsg %> </font> <font color="#006633"><%= noerror %> <br>
</font></td>
</tr>
<tr>
<td width="136">Start: *</td>
<td width="396">d.
<select name="startday" id="startday" class='textfield'>
<option value='0'>Dato</option>
<%
for n = 1 to 31
%>
<option value='<%= n %>' <% if startday = n then response.write(" selected")%>><%= n %></option>
<%
next
%>
</select>
/
<select name="startmonth" id="startmonth" class='textfield'>
<option value='0'>Måned</option>
<%
for n = 1 to 12
%>
<option value='<%= n %>' <% if startmonth = n then response.write(" selected")%>><%= n %></option>
<%
next
%>
</select>
/
<select name="startyear" id="startyear" class='textfield'>
<option value='0'>År</option>
<option value='2003'>2003</option>
</select>
kl.
<input name="starthours" type="text" id="starthours" value="<%= starthours %>" size="3" class='textfield'>
:
<input name="startmin" type="text" id="startmin" value="<%= startmin %>" size="3" class='textfield'></td>
</tr>
<tr>
<td>Slut:</td>
<td>d.
<select name="endday" id="endday" class='textfield'>
<option value='0'>Dato</option>
<%
for n = 1 to 31
%>
<option value='<%= n %>' <% if startday = n then response.write(" selected")%>><%= n %></option>
<%
next
%>
</select>
/
<select name="endmonth" id="select2" class='textfield'>
<option value='0'>Måned</option>
<%
for n = 1 to 12
%>
<option value='<%= n %>' <% if startmonth = n then response.write(" selected")%>><%= n %></option>
<%
next
%>
</select>
/
<select name="endyear" id="select3" class='textfield'>
<option value='0'>År</option>
<option value='2003'>2003</option>
</select>
kl.
<input name="endhours" type="text" id="endhours" value="<%= endhours %>" size="3" class='textfield'>
:
<input name="endmin" type="text" id="endmin" value="<%= endmin %>" size="3" class='textfield'>
</td>
</tr>
<tr>
<td valign="top">Navn: *</td>
<td><input name="eventname" type="text" id="eventname" value="<%= eventname %>" size="30" class='textfield'></td>
</tr>
<tr>
<td valign="top">Sted: *</td>
<td><input name="location" type="text" id="location" value="<%= location%>" size="35" class='textfield'></td>
</tr>
<tr>
<td>Pladser:</td>
<td><input name="capacity" type="text" class='textfield' id="capacity" value="<%= capacity %>" size="4" maxlength="3"></td>
</tr>
<tr>
<td>Pris:</td>
<td><input name="price" type="text" class='textfield' id="price" value="<%= price %>" size="4" maxlength="3"></td>
</tr>
<tr>
<td>Website:</td>
<td><input name="website" type="text" id="website" value="<%= website %>" size="35" class='textfield'></td>
</tr>
<tr>
<td valign="top">Beskrivelse: *</td>
<td><textarea name="eventdescription" cols="60" rows="15" id="eventdescription" class='textfield'><%= eventdescription %></textarea></td>
</tr>
<tr>
<td> </td>
<td><br> <br> <input type="submit" name="Submit" value="Gem arrangement" class='formbutton'></td>
</tr>
<tr align="center">
<td colspan="2"><br> <br> <a href="?page=11">Tilbage til administrationen</a></td>
</tr>
</table>
</form>
<%
elseif getmode() = "admin" then
if request.querystring("action") = "delete" then
SQL = "DELETE FROM eventmember WHERE eventid = " & request.querystring("id")
set RS = conn.execute(SQL)
SQL = "DELETE FROM calender WHERE id = " & request.querystring("id")
set RS = conn.execute(SQL)
response.redirect("?page=" & getpage() & "&mode=admin")
end if
SQL = "SELECT id, startdate, eventname FROM calender WHERE startdate > 0 - 60 ORDER BY startdate DESC;"
set RS = conn.execute(SQL)
%>
<table width="540" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td width="169"><strong>Dato</strong></td>
<td width="273"><strong>Navn</strong></td>
<td width="86"><strong>Handling</strong></td>
</tr>
<tr>
<td colspan="3" height='1' background='gfx/gif/dot.gif'></td>
</tr>
<tr>
<td colspan="3" height='10'></td>
</tr>
<% if RS.EOF then %>
<tr>
<td colspan="3">Ingen arrangementer fundet</td>
</tr>
<% else
do while not RS.EOF %>
<tr>
<td><% response.write(formatdatetime(RS("startdate"),2) & " kl. " & formatdatetime(RS("startdate"),4)) %></td>
<td><%= RS("eventname") %></td>
<td><a href="?page=<%= getpage() %>&mode=edit&id=<%= RS("id") %>">Rediger</a>
/ <a href="?page=21&mode=admin&action=delete&id=<%= RS("id") %>">Slet</a></td>
</tr>
<% RS.movenext
loop
end if %>
<tr>
<td colspan="3" height='10'></td>
</tr>
<tr>
<td colspan="3" height='1' background='gfx/gif/dot.gif'></td>
</tr>
<tr align="center">
<td colspan="3"><br>
<br>
<a href="?page=11">Tilbage til administrationen</a></td>
</tr>
</table>
<%
elseif getmode() = "edit" then
id = request.querystring("id")
SQL = "SELECT startdate, enddate, eventname, location, capacity, price, website, description FROM calender WHERE id = " & id
set RS = conn.execute(SQL)
startday = datepart("d", RS("startdate"))
startmonth = datepart("m", RS("startdate"))
startyear = datepart("yyyy", RS("startdate"))
starthours = datepart("h", RS("startdate"))
startmin = datepart("n", RS("startdate"))
endday = datepart("d", RS("enddate"))
endmonth = datepart("m", RS("enddate"))
endyear = datepart("yyyy", RS("enddate"))
endhours = datepart("h", RS("enddate"))
endmin = datepart("n", RS("enddate"))
eventname = replace(RS("eventname"),"''","'")
location = replace(RS("location"),"''","'")
capacity = RS("capacity")
price = RS("price")
website = RS("website")
eventdescription = replace(RS("description"),"''","'")
eventdescription = replace(eventdescription,"<BR>",vbcrlf)
if request.form("mode") = "update" then
err = 0
startdate = request.form("startday") & "-" & request.form("startmonth") & "-" & request.form("startyear") & " " & request.form("starthours") & ":" & request.form("startmin")
enddate = request.form("endday") & "-" & request.form("endmonth") & "-" & request.form("endyear") & " " & request.form("endhours") & ":" & request.form("endmin")
if len(enddate) < 14 then enddate = startdate
eventname = replace(request.form("eventname"),"'","''")
location = replace(request.form("location"),"'","''")
capacity = request.form("capacity")
price = request.form("price")
website = request.form("website")
eventdescription = replace(request.form("eventdescription"),"'","''")
eventdescription = replace(eventdescription,vbcrlf,"<br>")
if len(startdate) < 14 then
response.write(len(startdate) & " / " & startdate)
err = 1
errormsg = "<br>Feltet 'Start' er ikke udfyldt korrekt"
end if
if eventname = "" then
err = 1
errormsg = errormsg + "<br>Du skal skrive et navn"
end if
if location = "" then
err = 1
errormsg = errormsg + "<br>Du skal angive et sted"
end if
if not capacity = "" then
if isnumeric(capacity) = 2 then
err = 1
errormsg = errormsg + "<br>Feltet 'Pladser' må kun indeholde tal"
end if
end if
if not price = "" then
if isnumeric(price) = 2 then
err = 1
errormsg = errormsg + "<br>Feltet 'Pris' må kun indeholde tal"
end if
end if
if not website = "" then
if instr(website,"http://") = 1 or instr(website,".") = 0 then
err = 1
errormsg = errormsg + "<br>Feltet 'Website' er ikke udfyldt korrekt"
end if
end if
if eventdescription = "" then
err = 1
errormsg = errormsg + "<br>Du skal skrive en beskrivelse"
end if
if err = 1 then errormsg = errormsg + "<br>"
if err = 0 then
SQL = "UPDATE calender SET startdate = '" & startdate & "', enddate = '" & enddate & "', eventname = '" & eventname & "', location = '" & location & "', capacity = '" & capacity & "', price = '" & price & "', website = '" & website & "', description = '" & eventdescription & "' WHERE id = " & id
set RS = conn.execute(SQL)
noerror = "<br>Ændringerne blev gemt i databasen<br>"
end if
end if
%>
<form name="form1" method="post" action="default.asp?page=<%= getpage() %>&mode=edit&id=<%= id %>">
<input type='hidden' name='mode' value='update'>
<table width="540" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td colspan="2">Alle felter markeret med * skal udfyldes</td>
</tr>
<tr>
<td colspan="2"><font color="#990000"><%= errormsg %> </font> <font color="#006633"><%= noerror %>
<br>
</font></td>
</tr>
<tr>
<td width="136">Start: *</td>
<td width="396">d.
<select name="startday" id="select4" class='textfield'>
<option value='0'>Dato</option>
<%
for n = 1 to 31
%>
<option value='<%= n %>' <% if startday = n then response.write(" selected")%>><%= n %></option>
<%
next
%>
</select>
/
<select name="startmonth" id="select5" class='textfield'>
<option value='0'>Måned</option>
<%
for n = 1 to 12
%>
<option value='<%= n %>' <% if startmonth = n then response.write(" selected")%>><%= n %></option>
<%
next
%>
</select>
/
<select name="startyear" id="select6" class='textfield'>
<option value='0'>År</option>
<option value='2003' <% if startyear = "2003" then response.write(" selected")%>>2003</option>
</select>
kl.
<input name="starthours" type="text" id="starthours3" value="<%= starthours %>" size="3" class='textfield'>
:
<input name="startmin" type="text" id="startmin3" value="<%= startmin %>" size="3" class='textfield'></td>
</tr>
<tr>
<td>Slut:</td>
<td>d.
<select name="endday" id="select7" class='textfield'>
<option value='0'>Dato</option>
<%
for n = 1 to 31
%>
<option value='<%= n %>' <% if endday = n then response.write(" selected")%>><%= n %></option>
<%
next
%>
</select>
/
<select name="endmonth" id="select8" class='textfield'>
<option value='0'>Måned</option>
<%
for n = 1 to 12
%>
<option value='<%= n %>' <% if endmonth = n then response.write(" selected")%>><%= n %></option>
<%
next
%>
</select>
/
<select name="endyear" id="select9" class='textfield'>
<option value='0'>År</option>
<option value='2003' <% if endyear = "2003" then response.write(" selected")%>>2003</option>
</select>
kl.
<input name="endhours" type="text" id="endhours2" value="<%= endhours %>" size="3" class='textfield'>
:
<input name="endmin" type="text" id="endmin2" value="<%= endmin %>" size="3" class='textfield'>
</td>
</tr>
<tr>
<td valign="top">Navn: *</td>
<td><input name="eventname" type="text" id="eventname2" value="<%= eventname %>" size="30" class='textfield'></td>
</tr>
<tr>
<td valign="top">Sted: *</td>
<td><input name="location" type="text" id="location2" value="<%= location%>" size="35" class='textfield'></td>
</tr>
<tr>
<td>Pladser:</td>
<td><input name="capacity" type="text" class='textfield' id="capacity2" value="<%= capacity %>" size="4" maxlength="3"></td>
</tr>
<tr>
<td>Pris:</td>
<td><input name="price" type="text" class='textfield' id="price2" value="<%= price %>" size="4" maxlength="3"></td>
</tr>
<tr>
<td>Website:</td>
<td><input name="website" type="text" id="website2" value="<%= website %>" size="35" class='textfield'></td>
</tr>
<tr>
<td valign="top">Beskrivelse: *</td>
<td><textarea name="eventdescription" cols="60" rows="15" id="textarea2" class='textfield'><%= eventdescription %></textarea></td>
</tr>
<tr>
<td> </td>
<td><br> <br> <input type="submit" name="Submit2" value="Gem arrangement" class='formbutton'></td>
</tr>
<tr align="center">
<td colspan="2"><br> <br>
<a href="?page=21&mode=admin">Tilbage til oversigten</a></td>
</tr>
</table>
</form>
<%
end if
end sub
%>