updating results in empty records!!!!1

Discussion in 'PHP' started by ausgezeichnete, Nov 9, 2007.

  1. #1
    this is my code
    and i don't see the problem
    every time am trying to edit something it gives empty record
    
    <?php
    $conn=mysqli_connect("localhost","root","","cars");
    $result=mysqli_query($conn,"select * from login where username='".$username."'");
    $record=mysqli_fetch_array($result,MYSQLI_ASSOC);
    $fields=mysqli_fetch_fields($result);
    
    $id=addslashes($_REQUEST['id']);
    $username=addslashes($_REQUEST['username']);
    $password=addslashes($_REQUEST['password']);
    $gender=addslashes($_REQUEST['gender']);
    $email=addslashes($_REQUEST['email']);
    $sql=mysqli_query($conn,"UPDATE login SET email = '".$email."' , id ='".$id."' Where username = '".$username."' ");
    if(!$sql){echo"Wrongggggg";}
    
    
    PHP:

     
    ausgezeichnete, Nov 9, 2007 IP
  2. live-cms_com

    live-cms_com Notable Member

    Messages:
    3,128
    Likes Received:
    112
    Best Answers:
    0
    Trophy Points:
    205
    Digital Goods:
    1
    #2
    Is $username actually set on line 3? And why do you have an extra space at the end of your final query?
     
    live-cms_com, Nov 9, 2007 IP
  3. ausgezeichnete

    ausgezeichnete Peon

    Messages:
    54
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    yes the page sees the username in the url
    extra space to avoid being wrong!
    my probelm when i click update it gives empty my records in the database
    either ID to 0
    and email to empty
     
    ausgezeichnete, Nov 9, 2007 IP
  4. live-cms_com

    live-cms_com Notable Member

    Messages:
    3,128
    Likes Received:
    112
    Best Answers:
    0
    Trophy Points:
    205
    Digital Goods:
    1
    #4
    Are you sure id and email are being sent by the url correctly? Try echo $_REQUEST['id'] to see if it's working.

    I don't see why you need the space though...
     
    live-cms_com, Nov 9, 2007 IP
  5. ausgezeichnete

    ausgezeichnete Peon

    Messages:
    54
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    it worked thnxx
    i wrote
    echo $email after the code and it saw it
    but plz could u help me to output this
    header("location:showmydetails?username=<?php echo $username;?>");
    the syntax driving me crazy

    Edit/Delete Message
     
    ausgezeichnete, Nov 9, 2007 IP
  6. liam1412

    liam1412 Active Member

    Messages:
    387
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #6
    header("location:showmydetails?username=<?php echo $username;?>");
    PHP:
    You don't need the <?php echo bit as header is already within php

    Just this will do the trick

    header("location:showmydetails?username=$username");
    PHP:
     
    liam1412, Nov 9, 2007 IP