Hey allesammen!
Jeg har en lille side, med nogle asp funktioner..
Og når jeg så add'er til DB'en, vil jeg gerne have at den replacer ' med ´.. Det skal den gøre INDEN den add'er til min DB.
Nogle der har en løsning ?
Her er de koder der bruges til at skrive til DB'en:
(admin.asp)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
if session("login") = "" Then
Response.redirect("../admin/login.asp")
end if
%>
<% Session.LCID = 1030 %>
<% Response.Buffer = true %>
<html>
<head>
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1">
<META HTTP-EQUIV="Expires" CONTENT="wedensday">
<TITLE>_____/ Xsound.DANMARK ∞</TITLE>
<LINK REV="made" href="mailto:Xsound@xsound.dk">
<META NAME="keywords" CONTENT="Personally nothing">
<META NAME="description" CONTENT="My personally pages about...NOTHING !!">
<META NAME="author" CONTENT="Daniel">
<META NAME="ROBOTS" CONTENT="ALL">
<link rel="stylesheet" type="text/css" href="../style2.css">
<link rel="shortcut icon" href="../faviconX.ico" />
<script language="JavaScript">
<!--
function formCheck(formobj){
// Enter name of mandatory fields
var fieldRequired = Array("osk", "nyh", "ska");
// Enter field description to appear in the dialog box
var fieldDescription = Array("osk", "nyh", "ska");
// dialog message
var alertMsg = "Udfyld venligst følgende felter:\\n";
var l_Msg = alertMsg.length;
for (var i = 0; i < fieldRequired.length; i++){
var obj = formobj.elements[fieldRequired[i]];
if (obj){
switch(obj.type){
case "select-one":
if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
alertMsg += " - " + fieldDescription[i] + "\\n";
}
break;
case "select-multiple":
if (obj.selectedIndex == -1){
alertMsg += " - " + fieldDescription[i] + "\\n";
}
break;
case "text":
case "textarea":
if (obj.value == "" || obj.value == null){
alertMsg += " - " + fieldDescription[i] + "\\n";
}
break;
default:
}
if (obj.type == undefined){
var blnchecked = false;
for (var j = 0; j < obj.length; j++){
if (obj[j].checked){
blnchecked = true;
}
}
if (!blnchecked){
alertMsg += " - " + fieldDescription[i] + "\\n";
}
}
}
}
if (alertMsg.length == l_Msg){
return true;
}else{
alert(alertMsg);
return false;
}
}
// -->
</script>
</head>
<body>
<center><b>NYHEDER - SKRIV/SLET</b></center>
<form method="post" action="skrevet.asp" onsubmit="return formCheck(this);">
<table>
<tr>
<td>Osk</td><td><input type="text" name="osk"></td>
</tr>
<tr>
<td>Nyh</td><td><textarea name="nyh" rows="4" cols="18"></textarea></td>
</tr>
<tr>
<td>Ska</td><td><input type="text" name="ska"></td>
</tr>
<tr>
<td></td><td><input type="submit" value="Skriv"></td>
</tr>
<tr>
<td></td><td><a href="../koder.asp" target="popup" onclick=
"window.open('','popup', 'width=300,height=400,scrollbars=1' )">Special koder</a></td>
</tr>
</table>
</form>
<% dim rs, SQLstringK, Record, sngGns %>
<% intPage = Request("page")
If isNumeric(intPage) = False Or intPage < 1 Then
intPage = 1
End If
' ADODB connection objektet
Set Conn = Server.CreateObject("ADODB.Connection")
' Husk at angive den rigtige sti til din database
DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../db/db1.mdb")
' Åben databaseforbindelsen
Conn.Open DSN
set rs = server.createobject("adodb.recordset")
strSQL = "Select * from news Order By Id Desc"
rs.open strSQL, Conn,1,3
If Not (rs.BOF Or rs.EOF) Then
rs.PageSize = 21
rs.AbsolutePage = Intpage
intRecCount = rs.PageSize
intPageCount = rs.PageCount
Do while not rs.EOF and intRecCount > 0
strSQL = "select count(id) as found FROM news WHERE id = " & rs("id") & ""
Set record = Conn.Execute(strSQL)
Ialt = Record("found")
id = rs("id")
osk = Server.HTMLEncode(rs("osk"))
osk = Replace(osk,vbCrLf, "")
dato = Server.HTMLEncode(rs("dato"))
dato = Replace(dato,vbCrLf, "")
nyh = Server.HTMLEncode(rs("nyh"))
nyh = Replace(nyh,vbCrLf, "")
nyh = Replace(nyh, ":)", "<img src='../images/smile.gif'>")
nyh = Replace(nyh, ":D", "<img src='../images/bigsmile.gif'>")
nyh = Replace(nyh, ":O", "<img src='../images/w00t.gif'>")
nyh = Replace(nyh, "[b]", "<b>")
nyh = Replace(nyh, "[/b]", "</b>")
nyh = Replace(nyh, "[i]", "<i>")
nyh = Replace(nyh, "[/i]", "</i>")
nyh = Replace(nyh, "[u]", "<u>")
nyh = Replace(nyh, "[/u]", "</u>")
nyh = Replace(nyh, "[h1]", "<font size='4'>")
nyh = Replace(nyh, "[/h1]", "</font>")
ska = Server.HTMLEncode(rs("ska"))
ska = Replace(ska,vbCrLf, "")
%>
<b><%=osk%></b> - <a href="slet.asp?id=<%=id%>">Slet</a>
<%
intRecCount = intRecCount - 1
rs.MoveNext
Loop
If Clng(intPage) > 1 Then
Response.Write "<a href=default.asp?page=" & intPage - 1 & "><b>Sidste side</b></a>"
Else
Response.Write "<s>Sidste side</s>"
End If
Response.Write " | "
If Clng(intPage) < Clng(intPageCount) Then
Response.Write "<a href=default.asp?page=" & intPage + 1 & "><b>Næste side</b></a>"
Else
Response.Write "<s>Næste side</s>"
End If
Conn.Close
Set Conn = Nothing
End If
%>
</body>
</html>
(skrevet.asp)
<% Session.LCID = 1030
if session("login") = "" Then
Response.redirect("../admin/login.asp")
end if
Set Conn = Server.CreateObject("ADODB.Connection")
DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; "
DSN = DSN & "DBQ=" & Server.MapPath("../db/db1.mdb")
Conn.Open DSN
strSQL = "Insert into news (osk, dato, nyh, ska) values('" & Request.Form("osk") & "','" & DatePart("D",Now()) & "-" & DatePart("M",Now()) & "-" & DatePart("YYYY",Now()) & "','" & Request.Form("nyh") & "','" & Request.Form("ska") & "')"
Conn.Execute(strSQL)
Conn.Close
Set Conn = Nothing
Response.Redirect "admin.asp"
%>
[Redigeret d. 23/06-05 16:24:07 af Daniel Andersen][Redigeret d. 23/06-05 16:24:22 af Daniel Andersen]