Jump to content

connecting form and mysql


wanbinn

Recommended Posts

i am trying to connect a form with mysql using IIS server. however i failed and the internet browser indicates that there is an error in my code(where i highlighted).database name:human_diseasestable name:collectorcolumns:collectorID, collectorname, diseaseID, collectiondate,locationbelow is the code i hav written,pls help.thanks.*************************************************************<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title><style type="text/css"><!--.style1 {font-size: 56px}.style2 {font-size: 24px; }.style3 {font-size: 14px; }--></style><script LANGUAGE="JavaScript">function goToURL() { window.location = "/addcollector.asp"; }</script></head><% Set mConn = Server.CreateObject("ADODB.Connection") Set mCmd = Server.CreateObject("ADODB.Command") Set sql = Server.CreateObject("ADODB.Recordset") Set sql2 = Server.CreateObject("ADODB.Recordset") Set sql3 = Server.CreateObject("ADODB.Recordset") mConn.ConnectionString = "server=127.0.0.1;driver=MySQL;db=human_diseases;uid=root" mConn.Open%><body><h1 align="center" class="style1">Human Diseases</h1><p align="center">Current Record(s) </p><%collectorid=request.form("Collector ID")collectorname=request.form("Collector Name")diseaseid=request.form("Disease ID")collectiondate=request.form("Collection Date")location=request.form("Location")mCmd.ActiveConnection = mConn mCmd.CommandType = 1 'Text' mCmd.CommandText = "INSERT INTO collector (collectorID, collectorname, diseaseID, collectiondate,location) VALUES ('"&collectorid&"','"&collectorname&"','"&diseaseid&"','"&collectiondate&"','"&location&"')" sql.Open mCmd,,1,1 curreccollector() %> <%function curreccollector%><div align="center"> <table width="674" border="1"> <tr bgcolor="#CCFF66"> <td width="28">No.</td> <td width="98">Collector ID </td> <td width="189">Collector Name </td> <td width="105">Disease ID </td> <td width="105">Collection Date </td> <td width="109">Location</td> </tr> <%mCmd.ActiveConnection = mConn mCmd.CommandType = 1 'Text' mCmd.CommandText = "SELECT * FROM collector" 'Opening the record set based on the Query from mCmd' sql2.Open mCmd,,1,1 num=1 Do Until sql2.EOF collectorid=sql2.Fields("collectorID") collectorname=sql2.Fields("collectorname") diseaseid=sql2.Fields("diseaseID") collectiondate=sql2.fields("collectiondate") location=sql2.fields("location") %> <tr bgcolor="#339999"> <td><%=num%></td> <td><%=collectorid%></td> <td><%=collectorname%></td> <td><%=diseaseid%></td> <td><%=collectiondate%></td> <td><%=location%></td> </tr> <% sql2.MoveNext num=num+1 Loop sql2.Close %> </table> <% mCmd.CommandText = "SELECT COUNT(*) as vol FROM collector" sql3.Open mCmd,,1,1 sql3.movefirst do while not sql3.eof x=sql3("vol").value sql3.movenext loop %> Current record : <%=x%> </div></td> </tr> <% End Function%> </div><p align="center"> </p> <p align="center"><input type="button" name="Button" value="Add Record" onClick="goToURL()"> <input type="button" name="Button" value="Exit Window" onclick="java script:window.close()"> </p></body></html>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...