-2
<?php
$query1 = "select * from users where user_id=" . $_GET['user_id'];
$result = mysqli_query($conn, $query1);
$res = mysqli_fetch_array($result);
if (!$res) {
    die(mysqli_error($conn));
} else {
    echo "succeess";
}
?>
<form method="post" id="editform" action="Updateuser.php"><br/>
    <tr><td><b>User ID</b></td><td>
            <input type="text" name="user_id" style="width:450px;height:30px" value="<? php echo $res['user_id'] ?>" /></td></tr>
    <tr>
        <td><b>Name</b></td>
        <td>
            <input type="text" name="name" style="width:450px;height:30px" value="<?php echo $res['name'] ?>">
        </td>
    </tr>
    <tr>
        <td><b>Role</b></td>
        <td>
            <input type="text" name="role" style="width:450px;height:30px" value="<?php echo $res['role'] ?>">
        </td>
    </tr>
    <tr>
        <td><b>Password</b></td>
        <td>
            <input type=" text" name="password" style="width:450px;height:30px" value="<?php echo $res['password'] ?>">
        </td>
    </tr>
    <tr>
        <td align=right>
            <input type="submit" name="submit value" id="updatebutton" value="Update Record">
        </td>
    </tr>

whenever the code runs it says unknown colomn in where clause, i am sending user_id from the users page to this page. It is displaying user_id in the address bar but it is not fetching the whole record from the database and keeps on displaying that error. Note: My table has that colomn "user_id"

urfusion
  • 5,528
  • 5
  • 50
  • 87
Anonymus
  • 3
  • 2

1 Answers1

0

You have to change this:

$query1 = "select * from users where user_id=" . $_GET['user_id'];

to

$query1 = "select * from users where user_id='". $_GET['user_id']."'";
xmaster
  • 1,042
  • 7
  • 20