• 19-06-2022, 22:46:42
    #1
    Merhaba,

    Alt kategori sayfası yapıyorum fakat aşağıdaki şekilde uyarı aldım. 46. satırdaki uyarı 2. resimdeki işaretlediğim yere geliyor. Bu sorunu nasıl aşabilirim. array satırında hata veriyor.





    <?php require_once 'header.php'; ?>
    <?php require_once 'sidebar.php'; ?>
    
      <!-- Content Wrapper. Contains page content -->
      <div class="content-wrapper">
        <!-- Content Header (Page header) -->
    
        <!-- Main content -->
        <section class="content">
          <!-- Small boxes (Stat box) -->
          <div class="row">
    
      <section class="col-lg-12 connectedSortable">
    
        <?php if (@$_GET['yukleme']=="basarili") {?>
          <b style="color:green">İşleminiz başarılı bir şekilde gerçekleşmiştir.</b>
        <?php } elseif (@$_GET['yukleme']=="basarisiz") { ?>
        <b style="color:red">İşleminiz başarısız olmuştur.</b>
    
        <?php } ?>
    
        <div class="row">
          <div class="col-xs-12">
            <div class="box">
              <div class="box-header">
                <h3 class="box-title">Kategori</h3>
    
            <a href="kategori-ekle.php">  <button type="button"class="btn btn-primary" style="float:right">Kategori Ekle</button>
    </a>
              </div>
              <!-- /.box-header -->
              <div class="box-body table-responsive no-padding">
                <table class="table table-hover">
                  <tr>
                    <th>Kategori Sıra</th>
                    <th>Kategori Başlık</th>
                    <th>Git</th>
                    <th>Düzenle</th>
                    <th>Sil</th>
                  </tr>
    
                  <?php $altkategori=$baglan->prepare("SELECT * FROM altkategori where kategori_id");
    
    // While döngüsü kategorileri listeliyor
                 $altkategori->execute(array($_GET['katid']));
      while ($altkategoricek=$altkategori->fetch(PDO::FETCH_ASSOC)) { ?>
    
    
    
    
                  <tr style=" height:50px !important">
                    <td><?php echo $altkategoricek['alt_sira'] ?></td>
                    <td><?php echo $altkategoricek['alt_baslik'] ?></td>
                    <td> <a href="alt-kategori.php?katid=<?php echo $kategoricek['kategori_id'] ?>"><span style="width:65px height:35px" class="btn btn-info">Git</span></a></td>
                    <td><a href="kategori-duzenle.php?id=<?php echo $kategoricek['kategori_id'] ?>"> <span style="width:65px height:35px" class="btn btn-success">Düzenle</span>
          </a>
                  </td>
                    <td><a  href="yukle.php?kategorisil&id=<?php echo $kategoricek['kategori_id'] ?>" >
                      <span style="width:65px height:35px" class="btn btn-danger"  >Sil </span></td>
    
    
          </a>
    
                  </tr>
    
    
      <!-- .while döngüsünü yaptıktan sonra php etiketlerini kapatıyoruz. -->
    <?php } ?>
    
    
                </table>
              </div>
              <!-- /.box-body -->
            </div>
            <!-- /.box -->
          </div>
        </div>
    
    
            </section>
            <!-- right col -->
          </div>
          <!-- /.row (main row) -->
    
        </section>
        <!-- /.content -->
      </div>
      <!-- /.content-wrapper -->
      <?php require_once 'footer.php'; ?>
  • 19-06-2022, 22:48:03
    #2
    hocam php kodunda altta, array yerine yani şöyle olması lazım.

    $altkategori->execute(array("kategori_id"=>$_GET['id']));
  • 19-06-2022, 22:49:45
    #3
    hocam execute de bi hata yok. prepare sorgunda where kategori_id=? yapmanız gerekiyor.
  • 19-06-2022, 22:50:08
    #4
     <?php $altkategori=$baglan->prepare("SELECT * FROM altkategori where kategori_id=?");
    42. satırı bu şekilde değiştirip deneyin hocam
  • 19-06-2022, 23:09:44
    #5
    ahmtcn37 adlı üyeden alıntı: mesajı görüntüle
     <?php $altkategori=$baglan->prepare("SELECT * FROM altkategori where kategori_id=?");
    42. satırı bu şekilde değiştirip deneyin hocam


    Hocam hatayı giderdim çok teşekkür ederim ama bu seferde alt kategori yazıları gelmedi.








    <?php require_once 'header.php'; ?>
    <?php require_once 'sidebar.php'; ?>
    
      <!-- Content Wrapper. Contains page content -->
      <div class="content-wrapper">
        <!-- Content Header (Page header) -->
    
        <!-- Main content -->
        <section class="content">
          <!-- Small boxes (Stat box) -->
          <div class="row">
    
      <section class="col-lg-12 connectedSortable">
    
        <?php if (@$_GET['yukleme']=="basarili") {?>
          <b style="color:green">İşleminiz başarılı bir şekilde gerçekleşmiştir.</b>
        <?php } elseif (@$_GET['yukleme']=="basarisiz") { ?>
        <b style="color:red">İşleminiz başarısız olmuştur.</b>
    
        <?php } ?>
    
        <div class="row">
          <div class="col-xs-12">
            <div class="box">
              <div class="box-header">
                <h3 class="box-title">Kategori</h3>
    
            <a href="kategori-ekle.php">  <button type="button"class="btn btn-primary" style="float:right">Kategori Ekle</button>
    </a>
              </div>
              <!-- /.box-header -->
              <div class="box-body table-responsive no-padding">
                <table class="table table-hover">
                  <tr>
                    <th>Kategori Sıra</th>
                    <th>Kategori Başlık</th>
                    <th>Git</th>
                    <th>Düzenle</th>
                    <th>Sil</th>
                  </tr>
    
                  <?php $altkategori=$baglan->prepare("SELECT * FROM altkategori where kategori_id=?");
    
    // While döngüsü kategorileri listeliyor
    
                 $altkategori->execute(array($_GET['katid']));
      while ($altkategoricek=$altkategori->fetch(PDO::FETCH_ASSOC)) { ?>
    
    
    
    
                  <tr style=" height:50px !important">
                    <td><?php echo $altkategoricek['alt_sira'] ?></td>
                    <td><?php echo $altkategoricek['alt_baslik'] ?></td>
                    <td> <span style="width:65px height:35px" class="btn btn-info">Git</span></a></td>
                    <td><a href="kategori-duzenle.php?id=<?php echo $kategoricek['kategori_id'] ?>"> <span style="width:65px height:35px" class="btn btn-success">Düzenle</span>
          </a>
                  </td>
                    <td><a  href="yukle.php?kategorisil&id=<?php echo $kategoricek['kategori_id'] ?>" >
                      <span style="width:65px height:35px" class="btn btn-danger"  >Sil </span></td>
    
    
          </a>
    
                  </tr>
    
    
      <!-- .while döngüsünü yaptıktan sonra php etiketlerini kapatıyoruz. -->
    <?php } ?>
    
    
                </table>
              </div>
              <!-- /.box-body -->
            </div>
            <!-- /.box -->
          </div>
        </div>
    
    
            </section>
            <!-- right col -->
          </div>
          <!-- /.row (main row) -->
    
        </section>
        <!-- /.content -->
      </div>
      <!-- /.content-wrapper -->
      <?php require_once 'footer.php'; ?>
  • 19-06-2022, 23:23:27
    #6
    hocam while yerine foreach dener misin niyeyse while bazen sorun çıkarabiliyor.
  • 19-06-2022, 23:26:57
    #7
    omergunay adlı üyeden alıntı: mesajı görüntüle
    hocam while yerine foreach dener misin niyeyse while bazen sorun çıkarabiliyor.
    Yok hocam foreach de aşağıdaki hatayı veriyor.



  • 19-06-2022, 23:29:15
    #8
    hocam foreach kullanımı o şekilde değil

    $altkategoricek = $altkategori->fetchAll(PDO::FETCH_ASSOC);

    foreach($altkategoricek as $kat) {
    echo $kat["alt_sira"];
    }


    bu şekilde bi dener misin hocam.
  • 19-06-2022, 23:31:19
    #9
    echo $_GET["katid"]; ile urlden gelen kategori id sini yazdırıp kontrol ediniz sorgunuz bu id ye göre veriyi çağırıyor. Olmayan bir id de veri listelememesi normaldir.