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
    New Coder
    Join Date
    Feb 2008
    Posts
    14
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Not getting the values

    PHP Code:
    <?php
    function sql_quote($data) {
      if (
    get_magic_quotes_gpc()) {
      
    $data stripslashes($data);
      }

    return 
    addslashes($data);
    }
    $id sql_quote($_GET['id']);
    $action sql_quote($_GET['action']);
    include 
    'config.php';
    include 
    'opendb.php';
    $id mysql_real_escape_string($id); // helps protect against injections

            
    $query "SELECT * FROM `members` WHERE `id` = '{$id}' "
         
            
    $result mysql_query($query) or die(mysql_error());

    $name=$row['name'];
    $rank=$row['rank'];
    $lastname=$row['lastname'];
    $pos=$row['pos'];
    $s=$row['squad'];
    $asn=$row['asn'];
    $tour=$row['tour'];
    ?>

    <form name="update" action="edit_profile.php?action=edit method="post">
    Name:<input type="text" name="name" value="<?php print $name?>"/>
    Last name:<input type="text" name="lastname" value="<?php print $lastname?>"/>
    Rank:<input type="text" name="rank" value="<?php print $rank?>"/>
    Pos:<input type="text" name="pos" value="<?php print $pos?>"/>

    <input type="submit" name="submit" value="save"/>
    </form>
    It's not getting the values from database and put them into text fields.

    What am i doing wrong?

  • #2
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    You're missing:

    PHP Code:
    $row mysql_fetch_array $result ); // or mysql_fetch_assoc 
    Last edited by Mwnciau; 03-09-2008 at 03:33 AM.

  • #3
    New Coder
    Join Date
    Feb 2008
    Posts
    14
    Thanks
    1
    Thanked 0 Times in 0 Posts
    PHP Code:
    <?php
    function sql_quote($data) {
      if (
    get_magic_quotes_gpc()) {
      
    $data stripslashes($data);
      }

    return 
    addslashes($data);
    }
    $id sql_quote($_GET['id']);
    $action sql_quote($_GET['action']);
    include 
    'config.php';
    include 
    'opendb.php';
    $id mysql_real_escape_string($id); // helps protect against injections

            
    $query "SELECT * FROM `members` WHERE `id` = '{$id}' "
            
    $result mysql_query($query) or die(mysql_error());
            
    $row mysql_fetch_array($result);

    $name=$row['name'];
    $rank=$row['rank'];
    $lastname=$row['lastname'];
    $pos=$row['pos'];
    $s=$row['squad'];
    $asn=$row['asn'];
    $tour=$row['tour'];
    ?>

    <form name="update" action="edit_profile.php?action=edit" method="post">
    Name:<input type="text" name="name" value="<?php print $name?>"/>
    Last name:<input type="text" name="lastname" value="<?php print $lastname?>"/>
    Rank:<input type="text" name="rank" value="<?php print $rank?>"/>
    Pos:<input type="text" name="pos" value="<?php print $pos?>"/>

    <input type="submit" name="submit" value="save"/>
    </form>


    Still not working and not giving me an error either.

  • #4
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    or die(mysql_error());

  • #5
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,853
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Just echo your $query and copy the generated string. Try to execute it in mysql console or phpmyadmin interface, and check the result.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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