SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Formerly known as RockNRollPig Shpigford's Avatar
    Join Date
    Dec 2002
    Location
    Denver, CO
    Posts
    2,877
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    These sessions are giving me trouble

    What i'm trying to do is make a profile page where the user can update their profile...so i've got "editprofile.php" and "updateprofile.php"...when you click "submit" in "editprofile.php" it sends it to "updateprofile.php"...i had to make it so that people couldn't just update anybody's profile by changing the "id" in the url...so i made it where their ID has to equal the one being editing...but for some reason it keep saying the ID's aren't matching...but they are. Here's my "updateprofile.php"
    PHP Code:
    if (isset($_SESSION['player'])) 
    {
     
    $player=$_SESSION['player'];
     
    $id $_GET['id'];
     
    $yourID=mysql_query("SELECT * FROM users WHERE playername='$player'");
     
    $realID mysql_fetch_array($yourID);
      if (
    $id == $realID) {
     
    $sql "UPDATE monster_users SET 
             fullname='
    $fullname',
       bday='
    $bday',
       town_origin='
    $town_origin',
             bio='
    $bio', WHERE ID='$id'";
      if (@
    mysql_query($sql)) { 
       echo(
    "<p>Your profile has been updated.</p>"); 
      } else { 
       echo(
    "<p>Error updating profile: " 
            
    mysql_error() . "</p>"); 
     }
      }
      else {
     print 
    "Poop on you for trying to edit someone elses profile. Go back to the <A href='index.php'>MAIN GAME PAGE</a>.";
      exit (); 
      }
    }

    else {
    print 
    "Not logged in";


  2. #2
    ko pročita magarac :) boccio's Avatar
    Join Date
    Oct 2003
    Location
    belgrade
    Posts
    354
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if I understand u right, you state that IDs are equal (matching), but for some reason fail to pass " if ($id == $realID) { " part...

    did u try echoing $id, and $realID prior to if clause, or u just think they should be same?
    Vivvo CMS - Web publishing at your fingertips
    Mile voli disko, a ja belo kolumbijsko

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    Canada
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    um..correct me if I'm wrong..but your comparing an array to a string:

    PHP Code:
    $yourID=mysql_query("SELECT * FROM users WHERE playername='$player'");
    $realID mysql_fetch_array($yourID);
      if (
    $id == $realID) {
    //rest of code 
    shouldn't it be:
    PHP Code:
    $yourID=mysql_query("SELECT * FROM users WHERE playername='$player'");
    $realID mysql_fetch_array($yourID);
    $rid $realID["id"];
      if (
    $id == $rid) {
    //rest of code 
    [0]DemonicPuffin
    Co-Founder/Systems Developer
    0 Group / NekoBurst Web Networks

  4. #4
    Mal Reynolds Mandibal's Avatar
    Join Date
    Aug 2003
    Location
    Columbus
    Posts
    718
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    DemonicP is exactly right. Additionally this is a case where you dont need to do "select *" just do "select id". Your not using the rest of the data so in this case theres really no reason to select all.
    Erh

  5. #5
    Formerly known as RockNRollPig Shpigford's Avatar
    Join Date
    Dec 2002
    Location
    Denver, CO
    Posts
    2,877
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    DemonicPuffin...that was it...it's always little things that cause the problems....thanks!!

  6. #6
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    Canada
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah...the little things always seem to cause more grief/problems/frustration leading to yelling expletives in 3 different languages(by that I of course mean english,ruby and php ) and re-writing code a few hundred times I'd also suggest you implement mandibal's suggestion of only selecting the column(s) you need.
    [0]DemonicPuffin
    Co-Founder/Systems Developer
    0 Group / NekoBurst Web Networks


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
  •