Forums

ASP

This topic is locked

wrong command 'id = 1, 5'. not allowed

Posted 01 Dec 2005 12:39:06
1
has voted
01 Dec 2005 12:39:06 rafal norten posted:
dear developers,
i am beginner in dw mx.
i have problem with the next code.
it is that when i klick the first time to show a record it goes.
but when i klick another one i get this
wrong command 'id = 1, 5'. not allowed

i will be happy if some body can help me.
thank you very much
rafal
####################################
<%
Dim regyptnews
Dim regyptnews_numRows

Set regyptnews = Server.CreateObject("ADODB.Recordset"
regyptnews.ActiveConnection = MM_conkat_STRING
regyptnews.Source = "SELECT * FROM egyptnews ORDER BY ttime DESC"
regyptnews.CursorType = 0
regyptnews.CursorLocation = 2
regyptnews.LockType = 1
regyptnews.Open()

regyptnews_numRows = 0
%>
<%
Dim rbodyegyptnews__MM_ColParam
rbodyegyptnews__MM_ColParam = "1"
If (Request.QueryString("id1" <> "" Then
rbodyegyptnews__MM_ColParam = Request.QueryString("id1"
End If
%>
<%
set rbodyegyptnews = Server.CreateObject("ADODB.Recordset"
rbodyegyptnews.ActiveConnection = MM_conkat_STRING
rbodyegyptnews.Source = "SELECT * FROM egyptnews WHERE id1 = " + Replace(rbodyegyptnews__MM_ColParam, "'", "''" + " ORDER BY ttime DESC"
rbodyegyptnews.CursorType = 0
rbodyegyptnews.CursorLocation = 2
rbodyegyptnews.LockType = 3
rbodyegyptnews.Open()
rbodyegyptnews_numRows = 0
%>
<html>
<head>

<link rel="stylesheet" type="text/css" href="css/style.css">
<title></title>
</head>
<body RightMargin=0 topmargin="0" marginwidth="0" marginheight="0">
<br>
<table border="0" cellspacing="0" cellpadding="0">
<%
startrw = 0
endrw = HLooper1__index
numberColumns = 3
numrows = 1
while((numrows <> 0) AND (Not regyptnews.EOF))
startrw = endrw + 1
endrw = endrw + numberColumns
%>
<tr align="center" valign="top">
<%
While ((startrw <= endrw) AND (Not regyptnews.EOF))
%>
<td><table width="238" border="0" cellspacing="0" cellpadding="0" height="113">
<tr height="94">
<td valign="middle" bgcolor="#dcdcdc" width="145" height="94">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="style11" dir=rtl><img src="(EmptyReference!)" alt="" height="1" width="10" border="0"></td>
<td class="style11" dir=rtl><%=(regyptnews.Fields.Item("tcomments".Value)%> ...<br>
<span class="productLink"><A HREF="rightnews.asp?<%= Server.HTMLEncode(MM_keepBoth) & MM_joinChar(MM_keepBoth) & "id1=" & regyptnews.Fields.Item("id1".Value %>" class=ablue>» التفاصيل</a></span></td>
</tr>
</table>
</td>
<td bgcolor="#dcdcdc" width="92" height="94"><A HREF="rightnews.asp?<%= Server.HTMLEncode(MM_keepBoth) & MM_joinChar(MM_keepBoth) & "id1=" & regyptnews.Fields.Item("id1".Value %>" class=ablue><img src="<%=(regyptnews.Fields.Item("tpics".Value)%>" width="92" height="92" border="0"></a></td>
<td rowspan="2" bgcolor="white" width="1" height="122"><img src="pixel.gif" width=1></td>
</tr>
<tr height="21">
<td colspan="2" align="center" bgcolor="silver" width="237" height="21" class="stylem"><font size=2 color="black" face=arial><b><%=(regyptnews.Fields.Item("thead".Value)%></b></font></td>
</tr>
</table></td>
<%
startrw = startrw + 1
regyptnews.MoveNext()
Wend
%>
</tr>
<%
numrows=numrows-1
Wend
%>
</table>
<br>
<br>
<font face="Arial, Helvetica, sans-serif" size="3"><b><%=(rbodyegyptnews.Fields.Item("thead".Value)%></b></font><br>
<img src="<%=(rbodyegyptnews.Fields.Item("tpics".Value)%>" align="left" vspace="10" hspace="20">
<%
Response.Write(Replace((rbodyegyptnews.Fields.Item("tcommentb".Value),vbNewLine,"<br>")
%>
<br>
<br>
</body>
</html>
<%
rbodyegyptnews.Close()
Set rbodyegyptnews = Nothing
%>
<%
regyptnews.Close()
Set regyptnews = Nothing
%>

Replies

Replied 01 Dec 2005 13:43:49
01 Dec 2005 13:43:49 Dave Thomas replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
rbodyegyptnews.Source = "SELECT * FROM egyptnews WHERE <b>id1</b> = " +
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

i think your problem is here.
in your sql you are asking if ID1 = ID5 which it can't do, because ID should be set as a primary key in most cases.
field name should be 'id' or 'news_id', then when it is set to auto-increment as a primary key, it will assign a number to each record [which is the id].

so

<b>WHERE id = " + .............&lt;rest of code&gt;</b>

regards

Dave Thomas
<b>DMX Zone Manager</b>
Replied 01 Dec 2005 22:00:11
01 Dec 2005 22:00:11 rafal norten replied:
thank you dave,
i tryed this but it dosnt function.
i have changed id1 everywhere to id also in the table.
thanks again
rafal

Reply to this topic