Undefined index: id line 7

help me please
email me asap at
asmafayaz@hotmail.co.uk

<?php
    // Connect to database server
    $conn = mysqli_connect("mysql5", "fet12014211", "Milkshake12","fet12014211"); 


// Show a particular value.
$id = $_GET['id'];

    // SQL query
    $strSQL = "SELECT * FROM countries where iso_alpha3='" . $id . "'";




    // Execute the query (the recordset $rs contains the result)
    $dataset = mysqli_query($conn, $strSQL); 
    if(mysqli_error($conn)){ 
        echo "SQL Error: " . mysqli_error($conn); 
    } 
    // Loop the recordset $rs
    // Each row will be made into an array ($row) using mysql_fetch_array
    while($row = mysqli_fetch_array($dataset)) {

       # fetch associative array
    while ($row = $result->fetch_assoc()) {
        echo '<option value="'.$row["iso_alpha3"].'">'.$row["name"].'</option>';  
    }


      // Write the value of the column FirstName (which is now in the array $row)
     ?>

  <?php echo $row['1'];  ?>
  <?php echo $row['2'];  ?>
  <?php echo $row['3'];  ?>
   <?php echo $row['4'];  ?>
  <?php echo $row['5'];  ?>
   <?php echo $row['6'];  ?>
  <?php echo $row['7'];  ?>
  <?php echo $row['8'];  ?>


  <?php

      }

    // Close the database connection
    mysql_close();
    ?>

Some versions of PHP demand that you first initialize each variable before using it.
Therefore, if you are sure that there are no errors, then add this at the beginning of your php script;

error_reporting(0);

That should do

if you call your script like yourfile.php?id=1234
$id will be 1234

remove $id = $_GET['id']; from line 7 and paste this code should solve your problem . its better to fix the issue not turn off the error reporting

//Define & Sanitize variables 
$id='';
if (isset($_GET['id'])){
$id = strip_tags( trim($_GET['id']));

  } 
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.