ksamann
11-06-2007, 03:38 PM
Hello, I am writing a piece of code that post information from a form into a database. There is only one problem: when i have posted 10 different posts, my code gives the next post an id of 2. Like its not reading the whole number just the first digit. Here is the part of the code that gathers information about the highest unique ID and then gives the next post an id that is one number higher.
sql="SELECT UnID AS UnID FROM sfjbue ORDER BY UnID DESC LIMIT 1"
rs.Open sql, conn
Rompe=rs.Fields("UnID").Value
rs.close
rs.Open"SELECT * FROM sfjbue", conn
Antall=rompe+1
PostID="post_" & antall
UnID=antall
Navn=Request.Form("navn")
Kategori=Request.Form("kategori")
Overskrift=Request.Form("overskrift")
Intro=Request.Form("intro")
Tekst=Request.Form("tekst")
BildeURL=Request.Form("bilde")
Dato=FormatDateTime(date(), vblongdate)
Tid=FormatDateTime(now(),vblongtime)
%>
<%
sql="insert into sfjbue(PostID, UnID, Kategori, Navn, Overskrift, Intro, Tekst, BildeURL, Dato, Tid )values('" & PostID & "', '" & UnID & "', '" & Kategori & "', '" & Navn & "', '" & Overskrift & "', '" & Intro & "', '" & Tekst & "', '" & BiildeURL & "', '" & Dato & "', '" & Tid & "')"
conn.Execute sql
rs.close
conn.close
can some bright head figure this out for me. Please comment if I did not make myself clear.
thanks in advance
ksamann
sql="SELECT UnID AS UnID FROM sfjbue ORDER BY UnID DESC LIMIT 1"
rs.Open sql, conn
Rompe=rs.Fields("UnID").Value
rs.close
rs.Open"SELECT * FROM sfjbue", conn
Antall=rompe+1
PostID="post_" & antall
UnID=antall
Navn=Request.Form("navn")
Kategori=Request.Form("kategori")
Overskrift=Request.Form("overskrift")
Intro=Request.Form("intro")
Tekst=Request.Form("tekst")
BildeURL=Request.Form("bilde")
Dato=FormatDateTime(date(), vblongdate)
Tid=FormatDateTime(now(),vblongtime)
%>
<%
sql="insert into sfjbue(PostID, UnID, Kategori, Navn, Overskrift, Intro, Tekst, BildeURL, Dato, Tid )values('" & PostID & "', '" & UnID & "', '" & Kategori & "', '" & Navn & "', '" & Overskrift & "', '" & Intro & "', '" & Tekst & "', '" & BiildeURL & "', '" & Dato & "', '" & Tid & "')"
conn.Execute sql
rs.close
conn.close
can some bright head figure this out for me. Please comment if I did not make myself clear.
thanks in advance
ksamann