0

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();
    ?>

Edited by asma.fayaz.77: Undefined index: id line 7

4
Contributors
3
Replies
13
Views
3 Years
Discussion Span
Last Post by titos97
0

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

Edited by Webville312

0

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']));

  } 
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.