Results 1 to 11 of 11

Thread: setcookie (I will cut my hair)

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    259

    setcookie (I will cut my hair)

    In this code:

    $Sql = "select * from Member where UserName='$UserName' and Password='$Password'";
    $Result = mysql_query($Sql);
    while ($Row = mysql_fetch_array($Result))
    {
    setcookie ("VBZooM","$UserName",time()+604800);
    }

    --
    It give me this error

    Warning: Cannot add header information - headers already sent by (output started at C:\apache\htdocs\vbzoom\admin\config.php:27) in C:\apache\htdocs\vbzoom\login.php on line 54

    --
    How can I solve this error ? and what it's hte cause of this error ?

  2. #2
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    you cannot assign cookies before any other output, it has the the first thing on the page.

    I'm assuming that "config.php" is an include, try putting it before that and anything the might be before it.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    259

    ammmmm

    but I want ot set cookies if username and password is correct

  4. #4
    scoutt
    Guest
    if that is the first code on your page and the config.php file doesn't have any echo or <html> tags in it then you need to take out the spaces after the ?> in the config file.

    if the above is not true then you need to show us the code that you have above that line and the code in config.php

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    259

    Yes

    Yes there was one space I take it out, it's work now, thank you scoutt . Now I can fix my hair.

  6. #6
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    *** is with this hair thing dude ?

  7. #7
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    I think he was ripping it out over this minor problem. Will PHP ever not count white spaces so we all can sleep better at nights when working with cookies?
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  8. #8
    scoutt
    Guest
    I know, it is pretty stupid.

  9. #9
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    Originally posted by scoutt
    I know, it is pretty stupid.
    Which part PHP counting white spaces? or the fact he is pulling his hair out over this problem?
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  10. #10
    scoutt
    Guest
    as soon as I posted that I knew that was going to be the question. well I was talking about php but him pulling his hair out is a little stupid.

  11. #11
    Junior Member
    Join Date
    Jul 2002
    Location
    San Diego, CA, U.S.A
    Posts
    30
    Okay, I usually use sessions.. there a lot easier in my opinion..

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