+ Reply to Thread
Results 1 to 2 of 2




  

Thread: session details overwritten when submitting to datbase

      
  1. #1
    I'm New! oleerik is on a distinguished road
    Join Date
    November 6, 2008
    Posts
    2
    Rep Power
    0
    Feedback Score
    0

    Default session details overwritten when submitting to datbase

    Hello!
    Me and my body are making a system in PHP, the problem is that:
    When logging in the session will be:
    Code:
    Array ( [user_id] => 7 [username] => oleerik [crew] => 0 [rank] => 0 )
    But, when I submit something to the database, the session will be something like this:
    Code:
    Array ( [user_id] => 7 [username] => Array ( [0] => oleerik [username] => oleerik ) [crew] => 0 [rank] => 0 )
    Anyone have any idea what is happening?

    Let me know if you need more information. Here is one file that is submitting to the database:

    PHP Code:
    <?php require_once("includes/connection.php"); ?>
    <?php 
    require_once("includes/functions.php"); ?>
    <?php 
    require_once("includes/session.php"); ?>
    <?php 
    require_once("includes/constants.php"); ?>
    <?php 
        confirm_logged_in
    ();
    ?>
    <?php
        
    if(isset($_GET['id']) && isset($_GET['place']) && !isset($_GET['del'])){
            
            
    $id2 mysql_prep($_GET['id']);
            
    $place mysql_prep($_GET['place']);
            
            
    $query "UPDATE  `datafor_crew`.`assignments`  SET  ";
            switch (
    $place){
                case 
    0:
                    
    $query .= "`leader`  =  ";
                    break;
                case 
    1:
                    
    $query .= "`user1`  =  ";
                    break;
                case 
    2:
                    
    $query .= "`user2`  =  ";
                    break;
            }
            
    $query .= "'{$_SESSION['user_id']}'";
            
    $query .= " WHERE  `assignments`.`id`  ={$id2}";
            
    $result mysql_query($query);
            
    confirm_query($result);
        } elseif (isset(
    $_GET['id']) && isset($_GET['place']) && isset($_GET['del'])) {
                    
            
    $id2 mysql_prep($_GET['id']);
            
    $place mysql_prep($_GET['place']);
            
            
    $query "UPDATE  `datafor_crew`.`assignments`  SET  ";
            switch (
    $place){
                case 
    0:
                    
    $query .= "`leader`  =  ";
                    break;
                case 
    1:
                    
    $query .= "`user1`  =  ";
                    break;
                case 
    2:
                    
    $query .= "`user2`  =  ";
                    break;
            }
            
    $query .= "'0'";
            
    $query .= " WHERE  `assignments`.`id`  ={$id2}";
            
    $result mysql_query($query);
            
    confirm_query($result);
        }
    ?>
    <?php
        $query 
    "SELECT * FROM assignments WHERE 'crew' = {$_SESSION['crew']}";
        
    $result_set mysql_query($query);
        
    confirm_query($result_set);
        
    $result_array mysql_fetch_assoc($result_set);
    ?>
    <?php 
    include_once ("includes/header.php"); ?>
    <?php
        meny
    ();
    ?>
    <div class="content">
    <h1>Oppgaver</h1>
    <table class="assignments" border="1">
    <?php
        
        
    echo "<tr>";
        echo 
    "<td>" "Oppgavenavn" "</td>";
        echo 
    "<td>" "Tidspunkt" "</td>";
        echo 
    "<td>" "Dato" "</td>";
        echo 
    "<td>" "Beskrivelse" "</td>";
        echo 
    "<td>" "Ansvarlig" "</td>";
        echo 
    "<td>" "Deltaker 1" "</td>";
        echo 
    "<td>" "Deltaker 2" "</td>";
        echo 
    "</tr>";
        
        for (
    $i 0$i mysql_num_rows($result_set); $i++){
            if (isset(
    $_GET['showall'])){
                
    $show 1;
            }else{
                
    $show $result_array['status'];
            }
            if (
    $show == 1){
                echo 
    "<tr>";
                echo 
    "<td>" $result_array['name'] . "</td>";
                echo 
    "<td>" $result_array['hour'] . ":" $result_array['min'] . "</td>";
                echo 
    "<td>" $result_array['time'] . "</td>";
                echo 
    "<td>" $result_array['text'] . "</td>";
                echo 
    "<td>";
                if (
    $result_array['leader'] == 0) {
                    echo 
    "<a class='assignmentrow' href='assignments.php?id={$result_array['id']}&place=0'>Ta</a>";
                } else {
                    
    $query "SELECT username FROM users WHERE id = '{$result_array['leader']}'";
                    
    $result mysql_query($query);
                    
    confirm_query($result);
                    
    $username mysql_fetch_array($result);
                    echo 
    $username['username'];
                    if (
    $_SESSION['crew'] <= VARA){
                        echo 
    "(<a href='assignments.php?del=1&id={$result_array['id']}&place=0'>x</a>)";
                    }
                }
                echo 
    "</td>";
                echo 
    "<td>"
                if (
    $result_array['user1'] == 0) {
                    echo 
    "<a class='assignmentrow' href='assignments.php?id={$result_array['id']}&place=1'>Ta</a>";
                } else {
                    
    $query "SELECT username FROM users WHERE id = '{$result_array['user1']}'";
                    
    $result mysql_query($query);
                    
    confirm_query($result);
                    
    $username mysql_fetch_array($result);
                    echo 
    $username['username'];
                    if (
    $_SESSION['crew'] <= VARA){
                        echo 
    "(<a href='assignments.php?del=1&id={$result_array['id']}&place=1'>x</a>)";
                    }
                }
                echo 
    "</td>";
                echo 
    "<td>";
                if (
    $result_array['user2'] == 0) {
                    echo 
    "<a class='assignmentrow' href='assignments.php?id={$result_array['id']}&place=2'>Ta</a>";
                } else {
                    
    $query "SELECT username FROM users WHERE id = '{$result_array['user2']}'";
                    
    $result mysql_query($query);
                    
    confirm_query($result);
                    
    $username mysql_fetch_array($result);
                    echo 
    $username['username'];
                    if (
    $_SESSION['crew'] <= VARA){
                        echo 
    "(<a href='assignments.php?del=1&id={$result_array['id']}&place=2'>x</a>)";
                    }
                }
                echo 
    "</td>";
                echo 
    "</tr>";
                
            }

            
    $result_array mysql_fetch_assoc($result_set);
        }
        echo 
    $result_array['name'];
        
    ?>
    </table>
    <?php 
        
    if ($_GET['showall'] == 1) {
            echo 
    "<a class='noprint' href='assignments.php'>Vis aktive</a>";
        }
        else {
            echo 
    "<a class='noprint' href='assignments.php?showall=1'>Vis alle</a>";
        }

    ?>    
    </div>
    <?php require_once ("includes/footer.php"); ?>

  2. #2
    Grand Masters Colleen has a reputation beyond reputeColleen has a reputation beyond reputeColleen has a reputation beyond reputeColleen has a reputation beyond reputeColleen has a reputation beyond reputeColleen has a reputation beyond reputeColleen has a reputation beyond reputeColleen has a reputation beyond reputeColleen has a reputation beyond reputeColleen has a reputation beyond reputeColleen has a reputation beyond repute Colleen's Avatar
    Join Date
    September 22, 2006
    Location
    Canada
    Posts
    11,144
    Rep Power
    26
    Feedback Score
    0

    Default Re: session details overwritten when submitting to datbase

    hmm... I'm not sure and there's not too many programmers here, I've gotten a lot of help over at phpfreaks forum in the past, you might want to try there, they've always helped me rather quickly.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. About submitting articles
    By Colleen in forum General Promotion
    Replies: 28
    Last Post: Nov 8th, 2008, 11:36 am
  2. Directory Submitting / Forum Posting
    By Purple Rain in forum Services
    Replies: 1
    Last Post: Sep 19th, 2008, 10:49 am
  3. [WTH] Designer - Please read details
    By Jani in forum Templates/Graphics
    Replies: 0
    Last Post: Sep 17th, 2008, 7:17 am
  4. Replies: 0
    Last Post: May 4th, 2008, 6:14 am
  5. Replies: 2
    Last Post: Oct 5th, 2006, 1:20 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
WebTalkForums
WebTalkForums
Recent Forum Threads