tampil_produk.php

<?php
include "includes/koneksi.php";

echo "<table>";
  $sql=mysql_query("select * from produk order by id_produk desc");

  while ($r=mysql_fetch_array($sql)){
    $harga     = number_format($r[harga],0,",",".");
    $deskripsi = nl2br($r[deskripsi]); // membuat paragraf 
    $isi       = substr($deskripsi,0,220); // ambil sebanyak 220 karakter
    $isi       = substr($deskripsi,0,strrpos($isi," ")); // potong per spasi kalimat

    echo "<tr><td><img src='foto_produk/small_$r[gambar]' align=left hspace=20 border=0></td><td><b>$r[nama_produk]</b> <br /><br />
          $isi ... <a href=#>Selengkapnya</a></td></tr>
          <tr><td>Rp. <b>$harga</b> </td><td><a href=aksi.php?module=keranjang&act=tambah&id=$r[id_produk]><img src='images/beli.jpg' border=0></a></td></tr>
          <tr><td colspan=2><hr /></td></tr>";
  }
echo "</table>";
?>

Notice: Use of undefined constant harga - assumed 'harga' in C:\xampp\htdocs\php_template2\tampil_produk.php on line 8

Notice: Use of undefined constant deskripsi - assumed 'deskripsi' in C:\xampp\htdocs\php_template2\tampil_produk.php on line 9

Why does the error appears?

Thanks before.

use

$r['harga']

and

$r['deskripsi']
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.