Results 1 to 8 of 8

Thread: Beginner help

  1. #1

    Thread Starter
    Addicted Member kikelinus's Avatar
    Join Date
    Nov 2000
    Posts
    219

    Beginner help

    I just started reading tutorials on ASP...can someone tell me what's wrong with the following code??

    PHP Code:
    <HTML>
    <
    HEAD>
    <
    Title>Example</title>
    </
    HEAD>
    <
    BODY>

    <%  
        
    Response.Cookies("Colour") = "Red" 
        
    Dim Back
        Back 
    Request.Cookies("Colour")
        
    Response.Write("<font color=" Back ">Hello</font>")
    %>
    </
    BODY>
    </
    HTML

    I get the following error:
    Response object error 'ASP 0156 : 80004005'

    Header Error

    /MyWeb/Test.asp, line 8

    The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content.




    Thanks.

  2. #2
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    You already started to write HTML. The HTTP headers must be written before you send the HTML data. Cookies are set via HTTP headers, so you must set them before you write any HTML.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  3. #3
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089

    hi

    I dont think anything is wrong with the code neither do we need to set the headers in ur case.

    One guess would be that u r using a response.redirect in ur code down somewhere.

  4. #4

    Thread Starter
    Addicted Member kikelinus's Avatar
    Join Date
    Nov 2000
    Posts
    219
    I had to put the code before the html....solved. Thanks

  5. #5
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    hey kikelinus, where did u get ur tutorials from ?? i have a couple but i dont find them to be explaining certain things the way i like or in easy enough detail.

    secondly:
    I had to put the code before the html....solved. Thanks
    What do u mean? could u give me an example of how u fixed it pls ??

    thanx.

  6. #6

    Thread Starter
    Addicted Member kikelinus's Avatar
    Join Date
    Nov 2000
    Posts
    219
    Like this:

    PHP Code:
    <%  
        
    Response.Cookies("Colour") = "Red" 
        
    Dim Back
        Back 
    Request.Cookies("Colour")
        
    Response.Write("<font color=" Back ">Hello</font>")
    %>

    <
    HTML>
    <
    HEAD>
    <
    Title>Example</title>
    </
    HEAD>
    <
    BODY>

    </
    BODY>
    </
    HTML

    There is a good tutorial at www.planet-source-code.com, It is called "A practival guide to ASP".....

    Also, the program ASPEdit (can be downloaded from download.com), comes with a database tutorial.

  7. #7
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    thanx a lot.



    i owe u one man.


    ME (Michael)

  8. #8
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    lol, ur link has a bug (just thought u would like to know)

    u put a "period" after the .......com. here's the correct one:

    http://www.planet-source-code.com


    not trying to be mean

    ME (Michael)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width