Web Analytics Made Easy -
StatCounter Undefined Index error - CodingForum

Announcement

Collapse
No announcement yet.

Undefined Index error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Undefined Index error

    I am running this script an I am getting this error .How can I fix this.Thanks in advance



    Notice: Undefined index: konu_ekleyen in


    PHP Code:
    <?php
    try{
        
    $db=new PDO("mysql:host=localhost;dbname=blog","root","");
    }
    catch(
    PDOException $ex){
        echo 
    $ex->getMessage();
    }
    $islem=isset($_GET["islem"]);

    switch (
    $islem){
        case 
    "iletisim":

            break;
        case 
    "hakkımda":

            break;
        default:
            
    $v=$db->prepare("select * from konular");
            
    $v->execute(array());
            
    $x=$v->fetchAll(2);
            foreach (
    $x as $m){
                echo 
    $m["konu_ekleyen"];
            }
            break;
    }
    ?>

  • #2
    How can I fix this.
    use select konu_ekleyen from konular

    but essentially, the code can be simplified to make it less error prone.
    PHP Code:
    $v $db->query("select konu_ekleyen from konular");
    $v->setFetchMode(PDO::FETCH_COLUMN);
    foreach (
    $v as $value) {
        echo 
    $value;

    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

    Comment


    • #3
      Thank you

      Comment

      Working...
      X