0
<?php
include 'connect.php';
$conn = mysqli_connect($host, $user, $pass, $db);

if (!$conn) {
    die("KO" . mysqli_connect_error());
}

$id = $_GET['id'];

$sql = "select * from tblabc where id = '$id'";

if (mysqli_num_rows($sql)==0){
    echo 'ok';
} else {
    $data = mysqli_fetch_assoc($sql);
}
?>

this is my code to editing the table record. but when its executed occurs error "notice: Undefined index: id". how to resolved this issued. thx

2 Answers2

0
<?php
include 'connect.php';
$conn = mysqli_connect($host, $user, $pass, $db);

if (!$conn) {
    die("KO" . mysqli_connect_error());
}
if(isset($_GET))
{
$id = $_GET['id'];

$sql = "select * from tblabc where id = '$id'";

if (mysqli_num_rows($sql)==0){
    echo 'ok';
} else {
    $data = mysqli_fetch_assoc($sql);
}
}
else
{
 echo 'nothing received';
}
?>

Use the above code to check the validity of the get variable before using it.This way you'll be able to know where the error is coming from.

Black Mamba
  • 13,632
  • 6
  • 82
  • 105
0

you should try with this

$id  = '';
if(isset($_GET['id']) && $_GET['id'] != '')
{
    $id = $_GET['id']; 
    $sql = "select * from tblabc where id = '$id'";

    if (mysqli_num_rows($sql)==0){
        echo 'ok';
    } else {
        $data = mysqli_fetch_assoc($sql);
    }
}
else
{
echo 'Id Not Defined';
}
Rohit
  • 377
  • 3
  • 15