SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    ********* Poet X Q mano's Avatar
    Join Date
    Oct 2002
    Location
    Still Thulcandra
    Posts
    997
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Having trouble. Identify an id, and cluttered code...

    Hi, I'm in trouble here...

    I'm trying to enter data into a lookuptable with three fields. Two of which are keys. namely personid, groupid and roleid. The two first are keys.

    PHP Code:
    <?php
      $_GET
    ['gruppeid'] = is_numeric($_GET['gruppeid']) ? $_GET['gruppeid'] : "";
      
    $_GET['personid'] = is_numeric($_GET['personid']) ? $_GET['personid'] : "";
      
    $_GET['gruppeid'] = ( isset ($_GET['id']) ) ? $_GET['id'] : $_GET['gruppeid'];

      
    $_GET[gruppeid] = $_GET[gruppe];
      
    $_GET[personid] = $rad[id];

      if(
    $_GET['mode'] == 'meld_pa') {
        if (!empty(
    $_GET['gruppeid'])&& !empty($_GET['personid'])) {
            
    // var_dump($personid);
            
    $personid = (int)$_GET['personid'];
            
    $sqlmeldpaa "INSERT INTO medlemlookup (gruppeid, personid) 
    VALUES (
    $_GET[gruppeid]$_GET[personid])";
            
    $ok mysql_query($sqlmeldpaa) or die(mysql_error());
           } else {
            echo 
    "Kunne ikke melde på fordi gruppeid eller personid manglet";
        }
        }

    // HTML with select form for group and searchfield for persons


      
    $_GET[gruppe] = $gruppe ;
      
    $sqlskrivgruppe "SELECT id, navn FROM grupper 
    WHERE id = 
    $_GET[gruppe]";
      
    $resultskrivgruppe mysql_query$sqlskrivgruppe ) or die ( 'Velg en gruppe først...' );
      
    $radskrivgruppe mysql_fetch_array$resultskrivgruppe );
      echo 
    "<p class=los>$radskrivgruppe[navn]</p>";

      
    $resultat mysql_query($sql) or die(mysql_error());
        echo 
    "<p class=los>Resultat:</p>";
        echo 
    "<p class=skrift>";
        while (
    $rad mysql_fetch_array$resultat ))
        {
          
    $vpid $rad['id'];
          echo 
    "<a href='$PHP_SELF?search=$_GET[search]&mode=
    meld_pa&gruppe=
    $_GET[gruppeid]&personid=$rad[id]'><--</a> $rad[etternavn]";
          echo 
    $rad[fornavn]<br />";
        }
    ?>
    I've ommitted parts of the code that I didn't think was important...

    Problem is, I get the error message that no groupid or personid is selected... The URL form the GET thing turns out nice, and it shows both group and personid...

    Please help... I've been working on this for hours...

  2. #2
    SitePoint Wizard
    Join Date
    Oct 2001
    Posts
    2,686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    These two lines overwrites what is coming from the URL:
    $_GET[gruppeid] = $_GET[gruppe];
    $_GET[personid] = $rad[id];

    And you also needs quotes around the keys.

    -Helge


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
  •