Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jan 2012
    Location
    Slovakia
    Posts
    111
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Unhappy log out script fix

    Hi guys can somebody say me why it doesn't works? of course the basic log out function works... the user will be logged out cookies and session will be destructed but ... i need delete the row from table and nothing happen. Somebody? ( the collums have a good name )


    PHP Code:
    <?php
    session_start
    ();



    require_once 
    './includes/functions.php';
    connect();

    $cookies=$_COOKIE['pc'];
    $zmaz mysql_query("DELETE FROM pocitadlo_online WHERE cookies='$cookies'") or die("Udaje sa nezmazali!");
     
    if (
    $zmaz) {
    session_destroy();
    setcookie("web_user"""mktime(12,0,0,111990));
    setcookie("pc"""mktime(12,0,0,111990));


    header("location:index.php?clanok=login");
    } else { echo 
    "Problem s zmazanim zaznamov";}

    ?>

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,133
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    Debug debug debug

    Code:
    $sql ="DELETE FROM pocitadlo_online WHERE cookies='$cookies'"
    
    echo "<hr/>DEBUG SQL: " .  $sql . "<hr/>";
    
    $zmaz = mysql_query( $sql ) or die("Udaje sa nezmazali!");
    Look at what the DEBUG shows you. Look in your DB table to see if you *do* have a record that matches the value from the DEBUG.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Regular Coder
    Join Date
    Jan 2012
    Location
    Slovakia
    Posts
    111
    Thanks
    9
    Thanked 0 Times in 0 Posts

    debug

    Quote Originally Posted by Old Pedant View Post
    Debug debug debug

    Code:
    $sql ="DELETE FROM pocitadlo_online WHERE cookies='$cookies'"
    
    echo "<hr/>DEBUG SQL: " .  $sql . "<hr/>";
    
    $zmaz = mysql_query( $sql ) or die("Udaje sa nezmazali!");
    Look at what the DEBUG shows you. Look in your DB table to see if you *do* have a record that matches the value from the DEBUG.
    nothing and when i try

    Code:
    $sql ="DELETE * FROM pocitadlo_online WHERE cookies='$cookies'";
    
    show: DELETE * FROM pocitadlo_online WHERE cookies='Trki'
    
    But i have in pocitadlo_online raw where the collum has value Trki ....
    
    echo "<hr/>DEBUG SQL: " .  $sql . "<hr/>";
    and the code must be good or no? because when it would be , my session would be destroyed.
    Last edited by Trki; 01-12-2012 at 07:18 AM.

  • #4
    New Coder
    Join Date
    Jan 2010
    Posts
    29
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by Trki View Post
    Hi guys can somebody say me why it doesn't works? of course the basic log out function works... the user will be logged out cookies and session will be destructed but ... i need delete the row from table and nothing happen. Somebody? ( the collums have a good name )


    PHP Code:
    <?php
    session_start
    ();



    require_once 
    './includes/functions.php';
    connect();

    $cookies=$_COOKIE['pc'];
    $zmaz mysql_query("DELETE FROM pocitadlo_online WHERE cookies='$cookies'") or die("Udaje sa nezmazali!");
     
    if (
    $zmaz) {
    session_destroy();
    setcookie("web_user"""mktime(12,0,0,111990));
    setcookie("pc"""mktime(12,0,0,111990));


    header("location:index.php?clanok=login");
    } else { echo 
    "Problem s zmazanim zaznamov";}

    ?>
    Could you perhaps echo out sql issues/warnings?

    PHP Code:
    echo mysql_error(); 
    Just curious.

    At least do the following to sanity check your self:

    PHP Code:
    $cookies=$_COOKIE['pc'];
    $q_ "DELETE FROM pocitadlo_online WHERE cookies='$cookies'"
    $zmaz mysql_query($q_) or die("Udaje sa nezmazali!");

    echo 
    $q_
    That way you can see the query and perhaps run it manually to see what it returns.
    Last edited by fatecaresx13; 01-12-2012 at 07:33 AM. Reason: Added PHP tags ;)
    Nerd Stuff (code, rrdtool, monitoring, etc):

    blog.anthonyhurst.com

  • #5
    Regular Coder
    Join Date
    Jan 2012
    Location
    Slovakia
    Posts
    111
    Thanks
    9
    Thanked 0 Times in 0 Posts

    another part

    ah **** i found the problem.... in was in another part :/ it was automaticly inserting a new raw with this cookies ( which i think it was in this time deleted... but ... its may .... the server in one script to example:

    cookies=...
    delete cookies

    insert into table cookies

    its posible that the server took the cookies before the delete and dann he insert this " delete cookies " into the tab?

    but it fixed now. ok :P


  •  

    Posting Permissions

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