Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by Yahweh

  1. The WHERE clause is superfluous increases unnecessary overhead if you're trying to select all records. Do this instead:SELECT * From Unsnooped ORDER BY Sitecode ASC I don't use Access a lot, but I'm pretty sure your problem traces back to MS Access' handling of nulls. A null is not the same as an empty string, so if one of your RegionCode, ClinicGroup, or Snooped fields contains null data, it won't be returned in your dataset.
  2. 1. You can't change a page on your computer and hope that the page on your webserver is changed with it, you have to save your new page on top of your old page.Or, if you write database driven websites, such as a blog, then changes to your site occur automatically as you alter your database, so you can make changes to your site without having to upload new pages all the time.2. The best tool is a text editor. Notepad is the canonical tool among web developers (it was the first tool I ever used), but I like Notepad++ which is strictly a text editor with a few widgets like syntax highlighting, auto-indent, and tabbed browsing for editing multiple files at the same time.If you're building a site in .Net, then you must use Visual Web Developer. Otherwise, .Net is going to be really really hard.3. Brinkster is a good free Windows host, although they make their free hosting very difficult to find on their page. I don't know of any good free PHP hosts.You should know ahead of time that virtually all "free" hosts will put ads on your site. You will not find a decent free host that is ad free.If you want good hosting, you have to pay for it. But, until you actually know what you're doing and your website starts getting popular, then Brinkster free hosting will work just fine.Fortunately, the difference between free hosting and pay hosting is extremely cheap. With free hosts, you're lucky to get 100 MB of space and 1 GB of bandwidth, you'll have ads or popups inserted into your pages, and the URL to your page will look something like http://username.somehost.com. For $5 a month, you can get 200 GB of space, 3000 GB of bandwidth, no ads, a domain name, all sorts of add-ons like free support and databases, etc. Free hosts are essentially worthless compared to what you can get for a trivial $5 or $10 a month.4. There isn't one. The best free forum is the one that you can write yourself. I wrote my own software and couldn't be happier with it. Some people suggest PHPbb, but I hate PHPbb with a passion, it embodies everything in shoddy web design.I recommend avoiding forums for now. First, because if you don't even know how to upload pages to a server, and don't know anything about programming server side languages, then you're going to have a helluva time administrating a forum. What would you do when MySQL starts generating inexplicable glitches as it frequently does? What do you do when someone wants you to change some code? Second, because free hosts don't give you the amount of space or bandwidth needed to run a successful forum.
  3. The best way to learn to program is picking up a book and going through examples page by page.I learned Visual Basic 5 a long time ago by flipping through a textbook, I learned the language in less than a month. I didn't learn the language especially well because the book wasn't comprehensive, it didn't cover many important things like API calls and it didn't make things object abstraction seem very important.I learned HTML the same way, by picking up a book and going through it page by page. I picked up the language in a couple days, mastered it in a week or so.I learned ASP and SQL by trial and error, by reading tutorials on the internet. That was a bad idea. I was very fortunate to already know the VB language, but it literally took me years to become proficient at ASP. I learned ASP by setting my goals too high: I downloaded an ASP messageboard and modified the contents, and I picked up A LOT of bad programming habits because the board I modified was very poorly written. I know ASP as well as any professional, but it took me MUCH longer to learn the language than if I'd picked up a book.I learned VB.Net/C#t in the process of getting my degree in Computer Science. I learned next to nothing in my classes, it was a review of Visual Basic. I learned trivial things like connecting I learned the String.Format method, but I learned those from other students. I've been learning ASP.Net, which is distinct enough from application programming that its rightfully considered its own language, but I've not been able to find any comprehensive books on the subject, so I'm learning by trial and error, and although I'm very good at it, I think it will be a long time before I'm proficient.I learned Java and C++ from college, and my experience in college was invaluable because I would have never learned the languages by guess-and-test.More than anything I recommend borrowing a book from the library and learning how to program on your own. Books of those sorts gently guide you into a subject in and organized way than most internet tutorials. Additionally, when you have to type code from a book to your computer, you're actually internalizing the language rather than being a copy/paste script kiddy. Its possible learn things from the internet and become very good, but unless you're already a seasoned pro and just looking up a new technique for building tree data with SQL or dumping the results of a query into an array, then you're only going to slow yourself down by trying to learn a language from the internet.
  4. Yahweh

    PHP vs ASP.NET

    I programmed in PHP a long time ago, back in the early days of PHP3 and PHP4.PHP is good because its easy to install, its cross-platform compatible, and its free.It lets newbies connect to a database in a single line of code with its mysql_* family of functions, but as a consequence it lacks a data abstraction layer such as ADODB or <asp:sqlsource> found in other languages (I don't consider that good programming practice). It has some nuances that encourage bad programming habits, such as not requiring variable declaration before using them, lacking datatypes. It has some odd features like magic_quotes and register_globals that reduce code portability and open security holes. It also has some unintuitive typecasting, for instance:if ((string)"false" == (int)0) echo "true\n";// returns true for some reason To fix that problem, you have to use the triple equality operator, ===, which is just strange syntax.I made the switch from PHP to Classic ASP for a few reasons:- PHP variable don't need to be initialized before use. With ASP, you can force variable declaration by including <% Option Explicit %> at the top of every page. With .Net, you're required to declare variables before use.- PHP arrays are very slow, and software I write tends to be very array dependent. I learned a while ago that PHP arrays are really balanced trees that emulate an associative array, its a very different data structure than a linear array. An array is really a key/value pair, and $array[1] isn't the first element in an array, its a key/value pair where the key is "1". I consider that a disadvantage for two reasons. You get a little flexibility out of PHP's "array" syntax, but you pay a performance penalty. In Big O notation, php "arrays" execute in O(log n) time for any array lookup, whereas arrays in every other program execute in O(1) time (<--- best case performance). ASP and .Net arrays are linear arrays, so lookups occur in O(1) time.- Regex in ASP is easier.PHP has some major advantages over ASP when it comes to important functions like sending mail, uploading, manipulating images. With Classic ASP, you need to use COM objects for those purposes, which means you either have to buy those objects or hope they are included with your host. PHP's has those functions built in.I made the switch from ASP to ASP.Net for lots of reasons:- Code behind rocks. Less spaghetti code.- Compiled code helps to hide your source code from other developers who use your product. Compiled code also runs faster.- I write about 90% less code than I did before. Especially with VS.Net, I can create entire database-driven, AJAX-enabled sites without having to write a single line of code, those functions are encapsulated in the .Net controls.- Regex is EXTREMELY powerful: balanced expressions and named captures are a godsend. If you don't have a lot of experience working with Regex, or you've never tried to parse text with nested code, then you can't appreciate just how powerful the regex engine is.- Good XML support.- Try/Catch blocks are MUCH better than "on error resume next".- Lots and lots of namespaces for handling common functions like MD5 and SHA512 hashing, generic functions (similar to C++ template<t> structure).- Some web controls intrinsically support membership. The most challenging part of programming large websites is handling user accounts, user roles, security; .Net does it for you, and it saves you A LOT of time.- Very good object-oriented language, and the controls respond to events (like "click" events, "state changed" events, etc.).ASP.Net lets you use VB.Net, C#, J#, and a lot of other languages, but I prefer the Visual Basic flavor as my default language because blocks of code are easier to read than curly braces. A "}" can mean "end while", "end if", "end sub", "end function", but but "end if" only means "end if". Also, C#, for whatever reason, doesn't allow programmers to functions with optional / default parameters; that ability is maintained in VB.net. I like being able to declare optional parameters rather than a bunch of overloaded functions, so I stick VB.net for convenience and readability.There are a lot of plusses to ASP.net, and the future of all web development is moving in a .Net direction. So, saying that you know PHP and .Net looks good on a resume, but I generally think .Net is the best choice for developers.
  5. Yahweh


    Ick. Double ick.Before you do anything else, learn to write HTML and ASP by hand. WYSIWYG editors are notorious for creating ugly, bloated code (and code, mind you, that doesn't format correctly in non-IE browsers). And don't use Access if you plan to have more than 5 users connected to your site at any given time, and don't use Frontpage if you plan to do any kind of serious web development. Apart from the 90% of useless junk generated by frontpage, nothing is wrong with the fragment you've posted.Two things come to mind:1) Check your database. If the data in your database is URLEncoded, then you have a problem with record input, not record output.2) Check your code. According to your code, you're displaying fields like this:<a href="http://<%=FP_FieldURL(fp_rs,"www")%>"> The function FP_FieldURL is outputting your data, its the piece of code that's formatting your data incorrectly. Find that function and comment out any line of code that says "someVariable = Response.URLEncode(someVariable)". That will format everything correctly, but just be aware that doing so is a security issue, it leaves you open to XSS attacks.If you don't want to edit your function, then here is a possible solution:The variable fp_rs is most likely a recordset. In that case, you can access your field directly. Try modifying your code to look something like this: <a href="http://<%=fp_rs("www")%>"> If that doesn't work, you have to edit your functions. If you're still having problems, post the code for function FP_FieldURL, and any other functions called from it.
  6. Yahweh

    select reverse

    I think it would be nice if SQL had a syntax that allows you to say "Select incrementer as seats_available from some_table where incrementer between 1 and 10".I don't think you can actually get SQL to select a dynamic range like that, unless you have a table that lists all the possible seats. You probably need to handle your output by serverside code, by running through a loop of occupied seats and displaying only the unfilled seats.
  7. Yahweh

    New window

    Why would you need to do this serverside? Why not just use HTML to open your processing page in a new window?[preprocess.asp]<form action="process.asp" target="_blank">...<input type="submit" value="Go"></form> If you need to close your processing window and/or redirect the opener to another page, just use a java script: [process.asp]<%...' stuff...%><body onLoad="java script:opener.location='finish.asp';self.close();">
  8. Are you writing your own forum software (if so, what language)? Or installing pre-existing software like vBulletin?Writing your own software is a little more time consuming, but I've written plenty of boards, its not terribly difficult from a programming point of view.
  9. Yahweh


    First, there's no earthly reason why you have to do anything in your code behind.If you can't upgrade .Net 2.0 and use the <asp:menu> control, you can create dynamic menus with bulleted list control:<asp:BulletedList ID="BulletedList1" runat="server" DisplayMode="HyperLink" DataSourceID="SqlDataSource1" DataTextField="Title" DataValueField="ID"></asp:BulletedList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNetConnectionString %>" SelectCommand="Select ID, Title From Table"></asp:SqlDataSource> That will display a bulleted list of hyperlinks.If you want to use a repeater, its virtually the same thing: <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1"> <ItemTemplate> <div><a href="page.aspx?id=<%# DataBinder.Eval(Container.DataItem, "ID") %>"> <%# DataBinder.Eval(Container.DataItem, "Title") %></a></div> </ItemTemplate></asp:Repeater><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNetConnectionString %>" SelectCommand="Select ID, Title From Table"></asp:SqlDataSource> The methods above are for simple, linear menus. If you need nested lists or display a tree list, then you run into issues: SQL doesn't know how to create hiearchial data. I've run into that problem, and I found a good workaround here. Basically, you set two fields in your database, a "depth" field and a "lineage field". An example table looks like this: Some_Blog-----ID Category Parent Depth Lineage1 Computers 0 0 /1/2 Programming 1 1 /1/2/3 Cooking 0 0 /3/4 Parts 2 2 /1/2/4/5 Websites 1 1 /1/5/6 Languages 2 2 /1/2/6/7 Monitor 4 3 /1/2/4/7/8 Vegan 3 1 /3/8/9 VB.Net 6 3 /1/2/6/9/10 Soups 3 1 /3/10/11 C++ 6 3 /1/2/6/11/ Searching, sorting, and displaying that kind of table in a list is very easy. When you sort by Lineage ASC, you get a perfectly hiearchial list, and you can sepearate levels by indenting your fields based on the depth. Its easiest to do that with a repeater: <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1"> <ItemTemplate> <div style="margin-left:"<%# DataBinder.Eval(Container.DataItem, "depth") %>em"> <a href="page.aspx?id=<%# DataBinder.Eval(Container.DataItem, "ID") %>"> <%# DataBinder.Eval(Container.DataItem, "Category") %></a> </div> </ItemTemplate></asp:Repeater><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNetConnectionString %>" SelectCommand="SELECT ID, Category, Depth FROM Some_Blog ORDER BY Lineage"></asp:SqlDataSource> I use that kind of code and table structure on my own sites. The nice part about the code above is that it displays a data tree in a SINGLE query (and its very fast), whereas using nested repeaters require dozens and dozens of queries.
  10. The problem is obvious:Your markup reads like this:<select name="category" id="category" style="width:130px;">...<input name="Blog_01_Category" type="hidden" value="<%=rsCategories("Blog_01_Category")%>" /> But your code says this: strRequestBlog_01Category = Replace(CSTR(Request.Form("Blog_01_Category")), "'", "''", 1, -1, 1) You're dropdown list is called "category", but you don't ever Request.Form that value in your code. The element "Blog_01_Category" is your hidden element, which is apparently static. Change your code to this: strRequestBlog_01Category = Replace(CSTR(Request.Form("category")), "'", "''", 1, -1, 1) Just a syntax error in your SQL, you're missing a comma between 'beer' and 'c':'beer' 'c', '', 1, '', '', 'right' [...] ^ | needs a comma
  11. Without seeing the HTML code alongside the ASP, its hard to tell what's wrong. But the best way to troubleshoot this kind is error is setting your form's method to "get", so that can see your querystring. You never know, your error could be something really simple like mispelling the name of your dropdown list.If your querystring looks something "page.asp?Blog_01_Title=Hello&Blog_01_Category=&Blog_01_Intro=world", then probably the error has something to do with your HTML code. Your dropdown list should look like this: <select name="Blog_01_Category" size="10"><option value="1">Cat 1</option><option value="2">Cat 2</option><option value="3">Cat 3</option><option value="4">Cat 4</option><option value="5">Cat 5</option><option value="6">Cat 6</option></select> If you don't name your dropdown list, or set values in each of the options, then it isn't passed in the querystring collection.My last suggestion is to make sure your SQL code is correct. Your category field is probably an integer, but you have a line of code reading: strEnterSQL = strEnterSQL & "'" & strRequestBlog_01Category & "', " That's going to put single quotes around your Category, but MySQL can't implicitly convert string values to integer values. That kind of conversion would raise an error in other databases, but MySQL is apparently silencing the error. Try changing your code to this: strEnterSQL = strEnterSQL & strRequestBlog_01Category & ", "
  12. Use this: SELECT uni, rank as area_rank FROM ranking WHERE uni = 'Impreial' The "as area_rank" is an alias. It just renames your column to something else.You can also use this to display more rows: SELECT uni, rank as area_rank FROM ranking ORDER BY area_rank ASC
  13. Yes, I was trying to modify phpBB. I originally started using phpBB2 because it was free and popular, but the out-of-the-box version has a notorious reputation for security holes, so I followed the instructions on phpBBHacks.com to add a security mod. After my board was flooded with spam, I modified to add a CAPCHA, which elimiated 80% of the spam. Then I noticed the software is missing important features like a file upload, so I modified for that.I had 6 or 8 templates, which made it extremely difficult to update, because each template has to be modified seperately. Due to the difficulty of modifying phpBB, a mod was actually created specifically for the purpose of installing other mods... unfortunately, that auto-installer only works for the default phpBB template, and only works if the default template is unmodded. I eventually reduced down my templates to 1, just so I wouldn't have to spend hours and hours adding a single new mod to the software.Usually, I'm a huge advocate of the open source community, but only when the community can produce good software. No, my software isn't going to be released. It was written specifically for my site, not as an enterprise application.
  14. Quibble: I don't think most browsers will convert "<tagger>Blah</tagger>" to a comment. They'll usually display the word "Blah", so it would be the HTML equivalent of "<span>Blah</span>".
  15. I like the default layout, it looks very nice.But from a programming point of view, I hate phpBB with a vengeance. Simply the worst board software I've ever used. In addition to the templating system being impossibly complex, the structure of the database tables being misengineered, the sql queries abusing the JOIN to no end, my worst pet peeve had to be the bbCodes.- The bbCode module is 600+ lines long, all of the bbCode regexes are handtyped. You can't simply call a function called bbCodeParser and have it produce a regex for you, you have to type it yourself. Because regexes are handtyped, there is no consistent format to bbCodes or bbCode processing; that problem is especially evident in the awkward inconsistencies in bbCode formats, such as {size=12} and {quote="username"} (notice the parameter for the QUOTE code must appear in quotation marks or the tag will not process, but the parameter in the SIZE tag must not appear in quotation marks or it will not process).- its nearly impossible to add a new bbCode. The process requires editing 6 different files, adding 50 lines of code, writing your own regex, and hoping everything went smoothly (which is usually not the case).- On top of that, the parser it suffers from a bug where it can't parse nested bbCodes properly.After I apologized to my site's contributors for the 50th time about the shoddy board software and being unable to fix it, I decided I had enough of phpBB and I wrote my own software. (I'm happy to say that in the board system I wrote,called yBoard, my yCode module is 40 lines long, yCodes can be created with a single line of code or by adding a single record to the database, and it handles nested codes the way it should.)
  16. For Each student As String In studentInfo Console.WriteLine(student) Next See MSDN: Console.WriteLine(object): You're telling your program to print your student object, but it doesn't know how to format each field in the object. By default, it prints it out in serialized format, which means you have a line break after each field.Its better to use .Net's formatting to take care of the alignment of text for you. I recommend rewriting your Sub like this:Sub writeData() Console.WriteLine("Student Grade Report: 11/29/2006") Console.WriteLine("How to read this screen:") Console.Write("{0,-20}{1,-20}{2,-20}", "Name:", "Grade Average:", "Grade") Console.WriteLine("") For Each student In studentInfo 'don't cast student as String Console.WriteLine("{0,-20}{1,-20}{2,-20}", _ student.firstName & " " & student.LastName, _ student.examAverage, _ student.examGrade) Next End Sub
  17. I can show you the code, but if you want to understand it, then you have to understand that literally, the "VALUES (...)" clause is a recordset, fundamentally no different from the recordset returned by any SQL query. That might not mean much to you, until you realize that the following two queries are identical:INSERT INTO table (field1)VALUES ('monkey');INSERT INTO table (field1)SELECT 'monkey'; -- the query "SELECT 'monkey'" returns a single record with a single field containing the value 'monkey' As you can probably guess, its not that hard to alter many columns, its not different than writing a select statement with many columns. The following two queries are identical: INSERT INTO table1 (field1, field2, field3, field4)VALUES ('1', 'monkey', 'jesh', 'aspnetguy')INSERT INTO table1 (field1, field2, field3, field4)SELECT field1, field2, field3, field4FROM sometableWHERE [conditions] For your application, you might use this code: INSERT INTO acc_list (ID, article_title, date_added)SELECT Max(b.ID + 1), 'Article on monkeys', Now()FROM acc_list b Its very simple, and very intuitive. Just be aware of two things:1) Your select statement should contain exactly the number fields that you are updating.2) You will insert exactly the number of rows returned by your select statement. If your select statement returns 12 rows, you will insert 12 new rows into your table.
  18. Yahweh

    asp strip_tags()

    It just occurred to me, another way to get rid of cross site scripting is using something like this: Function sanitize_input(someString) santize_input = Server.HTMLEncode(someString)End Function That converts >, <, " (double quotes), and a few other characters to their harmless ascii equivalents, >, &lt, &quote;.
  19. That depends on what the dates are and which date you want to select.If you have records with duplicate names and surnames, and each record has the same date, then you don't need to change the query much at all.SELECT DISTINCT name, surname, `date` FROM table Otherwise, if the date is different for each record, then you need to use a join: SELECT DISTINCT a.name, a.surname, Max(b.`date`) FROM table aJOIN table b ON (a.id = b.id)GROUP BY a.name, a.surname Note: I haven't tested the queries above. I don't know if it will attempt to return rows with distinct max/min dates or not.
  20. Use this: INSERT INTO acc_list (ID)SELECT Max(b.ID + 1)FROM acc_list b Notice that the query above does not have a "VALUES (...)" clause. It doesn't need one because its using a SELECT.
  21. Yahweh

    Exclusive Join?

    I imagine that you have two tables like this: gallery_table-------------------------galleryID galleryTitle1 2007-01-012 2007-01-053 2007-02-174 2007-02-21image_tableimageID galleryID (foreign key goes back to gallery_table.galleryID)1 12 13 34 45 36 17 28 39 1 Its a helluva lot easier to add a "totalImages" column to your gallery table, and perform a simple "SELECT * FROM gallery_table" to get the number of images in each gallery. When you have 10s of 1000s of records, your queries begin to lag using a subquery or complex join.But, if you really want to go the route of using a join, you can do it two ways:Use a subquery: SELECT g.galleryid, g.gallerytitle, ( Select Count(*) FROM image_table i WHERE g.galleryID = i.galleryID ) as totalImagesFROM gallery_table g Use a join: SELECT g.galleryID, g.gallerytitle, i.Count(*) as totalImagesFROM gallery_table gLEFT JOIN image_table i ON (g.galleryID = i.galleryID)GROUP BY g.galleryID, g.galleryTitle The GROUP BY is needed because the count(*) is an aggregate function. As long as you're comparing galleryID's, then you won't get any records from your image table with a null value, so you don't need to use an INNER JOIN.
  22. This will work: SELECT DISTINCT name, surname FROM table;
  23. Most newbie programmers use Access. Then, when they get good at programming and move on to big projects, and wanting to build medium to high traffic websites, they claw out their eyes because Access just doesn't cut it. Then they switch to MySQL or SQL Server.If you want to use Microsoft technologies, go to ASP.Net. Classic ASP is essentially a dead language now, and the future of all web development is moving in a .Net direction. I recommend using SQL Server, but MySQL usually comes for free on most hosts.
  24. Yahweh

    asp strip_tags()

    You need to define your own strip_tags() function. You can strip tags easily with regex. Public Function strip_tags(someString) Dim myRegex Set myRegex = new regexp myRegex.global = True myRegex.IgnoreCase = true myRegex.Multiline = true myRegex.Pattern = "<[^> ]+[\s\S]*?>" 'matches any valid tag strip_tags = myRegex.Replace(someString, "")End Function You might need a more powerful regex, because that won't catch malformed tags. However, it should be good enough to get you started.
  • Create New...