Forum Moderators: open
Error Type:
ADODB.Recordset.1 (0x80004005)
SQLState: S1000 Native Error Code: 2013 [TCX][MyODBC]Lost connection to MySQL server during query
/messageboard/pages/posts.asp, line 22
Let me know when you're ready to go again and I'll continue to try and help you out.
This is actually a lot of fun. ;)
~gary.
FourDegreez:
In ASP/VBScript, there are default session variables and user defined session variables. An example of default session variables would be:
HTTP_HOST
HTTP_REFERER
HTTP_USER_AGENT
MM_UserAuthorization
MM_Username
MM_Username is also created by my login page. It contains the users login name and is used to determin if a user is logged in or not.
The test for both of these is simple as in this example taken from another one of my sites:
<%
' *** Restrict Access To Page: Grant or deny access to this page
MM_authorizedUsers="Member,Moderator,Super Moderator,Admin,Webmaster,Super Admin"
MM_authFailedURL="home.asp"
MM_grantAccess=false
If Session("MM_Username") <> "" Then
If (false Or CStr(Session("MM_UserAuthorization"))="") Or _
(InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1) Then
MM_grantAccess = true
End If
End If
If Not MM_grantAccess Then
MM_qsChar = "?"
If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"
MM_referrer = Request.ServerVariables("URL")
if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString()
MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer)
Response.Redirect(MM_authFailedURL)
End If
%>
Is this the type of setup you were refering to, if not, can you give me a php example?
HTTP_HOST
HTTP_REFERER
HTTP_USER_AGENT
The above are server variables, not session variables. :)
I'm always curious about people's choices. So I'm wondering why you decided to use ASP if you're not on a Windows box? I noticed on your error page that you're using SunOne ASP.
I'll check in later and see how the message board is coming along and offer whatever advice I can. I know my writing style seems harsh. It's not meant to be, I wish I could change it, so please don't take it that way.
The 100+ valadation errors are due to the repeat region I used in the VBScript. The validator is seeing the duplicated id's and chucking a wobbly because it doesnt like duplicate definitions. In actual fact, there was only about 2 genuine errors on the entire page although there may be more now because I just changed it to tables.
I had to change it to tables because the Mozilla Firefox browser was displaying 2 divides of 155px and 645px as longer than one 800px divide. The Mozilla line of browsers allways has had a problem with divides and although you can get around it, I cant be bothered. Tables will do exactly the same task with fewer complications.
I am on a windows box but using a commercial server to host my ASP sites because my Selisoft ASP server is in limbo at this current point in time. I am using ASP/VBScript because I had troubles writing pages in perl and although I know a little of other languages, I dont know enough to perform this sort of level of programing.
I saw a javascript somewhere which had a tag in it that was intended to make the javascript executed server side. I might give that a go and see what happens, might save me from having to re-write the substitution code.
At present, my login page set's MM_Username with your login name but MM_UserAuthorization is not in use at present. My reply page contains a hidden field (the one you saw before) which when the form is submitted, places the value of MM_Username into the username field of the post table.
What I'm saying is, instead of putting that hidden form field there with the value of MM_Username, grab the value from MM_Username on the page the form posts to instead and have no hidden field. You can grab the value from MM_Username at any time from any page, so there is no need to pass it in a hidden field.
Speaking of PHP, why have you ruled it out?
Please do a search for DOCTYPE. It's one of the most essential things to include in the first line of your .asp pages. For now your page looks much better in Firefox, but it's still throwing a ton of validation errors, starting with the absence of a DOCTYPE.
I decided not to use PHP because I am still learning it and dont know enough to write this level of code in it yet. About all I know of it at the moment asside from a few stray tags and the basic syntax is:
echo("hello world");
GaryK: Nah, what I saw was something like:
<Script language="Javascript" type="text/javascript" execute server side>
You can still post without logging in which is how I want it for now but I just added a new script which should stop you from posting without providing at least an anonymous user name for your post.
Also, I have not been able to get around to fixing the javascript problem yet but will tomorrow. For now, im going to get some sleep because its 2:30am.
Instead of "id" why not use "class" instead? The "id" property and a CSS element is only valid once per page whereas "class" can be used numerous times.
As for the DOCTYPE, why are you of the opinion that ASP doesn't need it? ASP outputs HTML just like a static .html page. DOCTYPEs and validation are just as relevant and important on an .asp page as an .html page.
I didnt say that the doctype wasnt needed, I simply didnt get around to putting it in yet but I have now and the page is now HTML 4.01 Transitional.
I havent had a chance to search for that javascript thing but it was being used in a perl or php page, not sure which.
<script language="javascript" type="text/javascript" runat="server"></script>
Found it:
Replace(expression, find, replacewith[, start[, count[, compare]]])
I substituted "<" and ">" with their non executable equivalents ">" and "<", do you think that is sufficient or can you think of some other substitution I should do?
FourDegreez: I have deleted that username form field that had the value of Session("MM_Username") and replaced it with a VBScript that writes the value of Session("MM_Username") directly to the database username field.
Let me know what you find out about the database issue. Maybe it would help if you posted the query that it's failing on. IIRC the error message mentioned a line number. What's on that line?
rsPosts.Open() If it happens again, I will take note of it but I think its the same part of the code every time.
My connection is this:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%><%
Dim rsPosts__MMColParam
rsPosts__MMColParam = "1"
If (Request.QueryString("board_id") <> "") Then
rsPosts__MMColParam = Request.QueryString("board_id")
End If
%>
<%
Dim rsPosts
Dim rsPosts_numRows
Dim MM_messageboard_STRING
MM_messageboard_STRING = "Driver=Driver; Server=Server; Database=Database; UID=UID; PWD=PWD"
Set rsPosts = Server.CreateObject("ADODB.Recordset")
rsPosts.ActiveConnection = MM_messageboard_STRING
rsPosts.Source = "SELECT * FROM post WHERE board_id = " + Replace(rsPosts__MMColParam, "'", "''") + " ORDER BY post_id ASC"
rsPosts.CursorType = 0
rsPosts.CursorLocation = 2
rsPosts.LockType = 1
rsPosts.Open()
rsPosts_numRows = 0
%>
Ok, if anyone can find a problem with that connection which would cause a lost connection to database during queery line 22 error, please let me know.
The page cannot be displayed
There is a problem with the page you are trying to reach and it cannot be displayed. --------------------------------------------------------------------------------
Please try the following:
Click the Refresh button, or try again later.
Open the www.whatever.com.au home page, and then look for links to the information you want.
HTTP 500.100 - Internal Server Error - ASP error
Apache/1.3.29 (Unix) Sun-ONE-ASP/4.0.0 ApacheJServ/1.1.2 PHP/4.3.4 mod_throttle/2.11 FrontPage/5.0.2.2634 Rewrit/1.1a
--------------------------------------------------------------------------------
Technical Information (for support personnel)
Error Type:
ADODB.Recordset.1 (0x80004005)
SQLState: S1000 Native Error Code: 2013 [TCX][MyODBC]Lost connection to MySQL server during query
/messageboard/pages/boards.asp, line 15
Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
Page:
GET /messageboard/pages/boards.asp
Time:
Sunday, May 01, 2005, 3:05:29 AM
More information:
Sun ONE Active Server Pages Support
Oh, there we go. Its a unix server.
Well thats the error I got when I tried to access the page so with all this information about my connection and the error I got, can anyone see what the problem is?
Is FourDegreez still here? If so, you suggested simply throwing a simple message board up there and then expanding on it. I have the register, login, boards, posts and reply pages up there now and they work well enough to look at advancing the project to the next step. In your experience, is there anything else that I might need to setup now or be aware of to save on problems later or can I just move onto adding more functionallity?
From what I can see, I still need to add an edit post page, delete post page, preview post page, profiles pages in general and control panel. Whilst I wait for your reply, I will begin on the edit and delete pages.
Note: Please do not be put off by the look of the message board, I just added a bit of color to make it easier to read. The overall look of the message board will be completely changed before we are finished.
FWIW I advise against letting members delete their own posts. Every site I've seen that allows it has wound up with more trouble than it's worth. Someone will post something inflammatory, wait until people attack him/her, delete the message that started it all and claim they don't understand why people are being so mean.
Please let me know when the db problem has been fixed and I'll try to resume helping you again.
I must thank you all very much for your help, it is an interesting experience and I am already amazed with the amount of things I didnt know about message boards. I am learning at an astronomical rate and getting better all the time. When we are done, if I ever do design a message board, I will be sure to note in it those here who have helped so much.
I will let you know when they get the problem resolved.
I do not take this to heart, everybody is entitled to their own opinion. I have never tried to hide the fact that I am not the greatest coder that this world has ever seen and I do not intend to. If people do decide to help me for whatever reason, I realize that it is my responsibility to let them know what level I am at so that they can provide information which would be of some use to me.
As such, I would like to make it very clear right now that my first computer was a commodore64. I learned commodore64 basic and touched on some machine code, afterwhich I advanced to a 286. I quickly picked up QBasic, which I became very proficient at. After a year of two I moved onto Borland C++ ver 4.0 which being from a basic language background, I found very daunting. Once I moved onto Microsoft Visual C++, I began to find it a little easier and started to get a grasp for object oriented programing. Next, I moved onto HTML which was not very hard at all to learn. I had a brief incounter with DHTML but found it more convenient to use pre written codes rather than writing them myself. After that, I setup my first web server using Abyse web server in conjunction with GuildFTP and shortly after learned Perl. Then I moved onto Apache with MySQL and started learning ASP. I have been using Apache, ASP and MySQL for only about 2-3 months now. I make no secret of the fact that I use dreamweavers GUI to insert pre written code into my pages for the sake of ease and convenience. I would sooner use dreamweavers pre written login and databasing routines which work perfectly fine and then edit them than spend hrs writing it all myself. I am a very quick learner when its something that interests me and with a 129 IQ im inteligent enough to understand what im being told if you use simple laymens terms and dont use confusing terminology. The only thing standing between me and a very successfull career is the breakdown between my short term and long term memory. I touched on PHP but have put learning it on hold for this project.
I am extremely greatful for any and all assistance I receive from the members here at WW and endeavour to conduct myself in a manner befitting one of its members. Should I advance this project to a fully functional production model one day, I will do the right thing and give credit where it is due to those who have helped me so much to achieve that potential.
Is the login stuff working yet? I ask because I was able to post without logging in.
Also, when accepting form input you need to validate it a bit more than whatever you're doing. For example, I was able to post a message by using a blank space as my name. Dealing with it is as simple, in this case, as using Trim to remove leading and trailing blank spaces from both the name and message form fields.