Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP/MySQL won't select or Insert! Help!

Status
Not open for further replies.

peeechy3

Programmer
May 18, 2004
10
GB
I am completely new to using a MySQLDB but I'm surprised that this doesn't work. Basically, I'm selecting all records from my NEWS database table.

There are definately two rows of test data in the NEWS table so they should be fetched row by row, but without the loop on, nothing is returned. With the loop on, nothing is returned again, but it takes longer. This suggests to me that there is a looping issue but I have used this same syntax on many loops in VBScript and without the loop, nothing is returned.

Any ideas?

The Code:

<PRE>
<HTML>
<head>
<title></title>
</head>
<%
ON ERROR RESUME NEXT
DebugMode = "True"

TodaysDate=Date()
TodaysDate_D=Day(TodaysDate)
TodaysDate_M=Month(TodaysDate)
TodaysDate_Y=Year(TodaysDate)

SQL=" SELECT TITLE, PUB_DATE, PARA1, PARA2, PARA3, PARA4, PARA5, PARA6, PARA7, PARA8 "
SQL=SQL &" FROM NEWS "
SQL=SQL &" WHERE PUB_DATE >= '" & TodaysDate & "' "

Set rs = Server.CreateObject("ADODB.RecordSet")
rs.ActiveConnection = "Driver={MySQL}; DATABASE=Blah; UID=Blah; PASSWORD=Blah; Server=Blah;"
rs.Open SQL, strConnect,3,3
%>
<body>
<table>
<tr>
<td>TITLE</td>
<td>PUBLICATION DATE</td>
<td>PARAGRAPH 1</td>
<td>PARAGRAPH 2</td>
<td>PARAGRAPH 3</td>
<td>PARAGRAPH 4</td>
<td>PARAGRAPH 5</td>
<td>PARAGRAPH 6</td>
<td>PARAGRAPH 7</td>
<td>PARAGRAPH 8</td>
</tr>
<% If Not rs.eof Then
On Error Resume Next
rs.MoveFirst
do while Not rs.eof
%>
<tr>
<td>&nbsp;<%=Server.HTMLEncode(rs.Fields("TITLE").Value)%></td>
<td>&nbsp;<%=Server.HTMLEncode(rs.Fields("PUB_DATE").Value)%></td>
<td>&nbsp;<%=Server.HTMLEncode(rs.Fields("PARA1").Value)%></td>
<td>&nbsp;<%=Server.HTMLEncode(rs.Fields("PARA2").Value)%></td>
<td>&nbsp;<%=Server.HTMLEncode(rs.Fields("PARA3").Value)%></td>
<td>&nbsp;<%=Server.HTMLEncode(rs.Fields("PARA4").Value)%></td>
<td>&nbsp;<%=Server.HTMLEncode(rs.Fields("PARA5").Value)%></td>
<td>&nbsp;<%=Server.HTMLEncode(rs.Fields("PARA6").Value)%></td>
<td>&nbsp;<%=Server.HTMLEncode(rs.Fields("PARA7").Value)%></td>
<td>&nbsp;<%=Server.HTMLEncode(rs.Fields("PARA8").Value)%></td>
</tr>
<% rs.MoveNext
loop
Else %>
<tr>
<td colspan="4">No Cases found matching the criteria!</td>
</tr>
<% End If %>
</table>
<%
If DebugMode = "True" Then
%>
SQL Code = <%=SQL%><BR>
<%=TodaysDate%>
<%
End If
%>
</body>
</html>
</PRE>
 
I'm not a PHP user, so this is just a shot in the dark:

What format is the variable TodaysDate in? For your SQL to work properly, it must be in the form 'yyyy-mm-dd' or 'yyyymmdd'. To be sure, you could use instead:[tt]
WHERE PUB_DATE >= CURDATE()[/tt]


-----
ALTER world DROP injustice, ADD peace;
 
Hi,

I'm using ASP not PHP so don't worry.

The date is in YYYY-MM-DD format, but thanks.

I've deduced that I have a locked host as I've made too many interupted connections so I need to get that sorted first now.

I think the select is a VBScript prob mind.

Thanks for your help anyway.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top