WordPress.org

Ready to get started?Download WordPress

Forums

Parse error: syntax error, unexpected $end in C:\xampp\htdocs\apotik1\Untitled-1 (4 posts)

  1. heriodk77
    Member
    Posted 1 year ago #

    I am getting this message, and do not know why. does anybody know why? (line 307 is the last line of code)
    Hope you can help, Thanks!
    Here is my untitle-1.php code:
    <?php require_once('Connections/farmasi.php'); ?>
    <?php

    function rupiah($angka){
    $rupiah = number_format($angka,0,',','.');
    return $rupiah;

    $kode = $_POST['kode_barang'];
    $nama = $_POST['nama_obat'];
    $kategori = $_POST['nama_kategori'];
    $kemasan = $_POST['kmsn'];
    $isi = $_POST['isi'];
    $satuan = $_POST['sat'];
    $harga = $_POST['h_kemasan'];
    $pajak = $_POST['ppn'];
    $nilai = '$harga' / '$pajak';
    $hs_ppn = '$harga' + '$nilai';
    $hss_ppn = '$hs_ppn' / '$isi';
    $stok = $_POST['stol'];
    $sql = "INSERT INTO tbl_name (kode_barang, nama_obat, nama_kategori, kmsn, isi, sat, h_kemasan, ppn, nilai, hs_ppn, hss_ppn, stol) VALUES ('$kode', '$nama', '$kategori', '$kemasan', '$isi', '$satuan', '$harga', '$pajak', '$nilai', '$hs_ppn', '$hss_ppn', '$stok')";
    $hasil = mysql_query($sql);

    if ($hasil) {
    echo "<script language='javascript'>alert('Data berhasil disimpan');</script>";
    } else {
    echo "<script language='javascript'>alert('Data tidak berhasil disimpan');</script>";
    }

    if ($nama == $_POST['nama_obat']) {
    echo "<script language='javascript'>alert('Nama Barang berhasil disimpan');</script>";
    } else {
    echo "<script language='javascript'>alert('Nama Barang yang anda input sama');</script>";
    }

    $currentPage = $_SERVER["PHP_SELF"];

    $maxRows_obat = 10;
    $pageNum_obat = 0;
    if (isset($_GET['pageNum_obat'])) {
    $pageNum_obat = $_GET['pageNum_obat'];
    }
    $startRow_obat = $pageNum_obat * $maxRows_obat;

    mysql_select_db($database_farmasi, $farmasi);
    $query_obat = "SELECT * FROM tbl_name ORDER BY id_barang ASC";
    $query_limit_obat = sprintf("%s LIMIT %d, %d", $query_obat, $startRow_obat, $maxRows_obat);
    $obat = mysql_query($query_limit_obat, $farmasi) or die(mysql_error());
    $row_obat = mysql_fetch_assoc($obat);

    if (isset($_GET['totalRows_obat'])) {
    $totalRows_obat = $_GET['totalRows_obat'];
    } else {
    $all_obat = mysql_query($query_obat);
    $totalRows_obat = mysql_num_rows($all_obat);
    }
    $totalPages_obat = ceil($totalRows_obat/$maxRows_obat)-1;

    mysql_select_db($database_farmasi, $farmasi);
    $query_kategori = "SELECT * FROM kategori_barang";
    $kategori = mysql_query($query_kategori, $farmasi) or die(mysql_error());
    $row_kategori = mysql_fetch_assoc($kategori);
    $totalRows_kategori = mysql_num_rows($kategori);

    $queryString_obat = "";
    if (!empty($_SERVER['QUERY_STRING'])) {
    $params = explode("&", $_SERVER['QUERY_STRING']);
    $newParams = array();
    foreach ($params as $param) {
    if (stristr($param, "pageNum_obat") == false &&
    stristr($param, "totalRows_obat") == false) {
    array_push($newParams, $param);
    }
    }
    if (count($newParams) != 0) {
    $queryString_obat = "&" . htmlentities(implode("&", $newParams));
    }
    }
    $queryString_obat = sprintf("&totalRows_obat=%d%s", $totalRows_obat, $queryString_obat);
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    <style type="text/css">
    <!--
    .style1 {
    font-family: Geneva, Arial, Helvetica, sans-serif;
    font-size: small;
    }
    .style2 {font-family: Geneva, Arial, Helvetica, sans-serif; font-size: medium; }
    .style3 {
    font-family: Geneva, Arial, Helvetica, sans-serif;
    font-weight: bold;
    }
    .style4 {font-size: small}
    .style6 {font-family: Verdana, Arial, Helvetica, sans-serif}
    .style7 {font-family: Geneva, Arial, Helvetica, sans-serif}
    .style8 {font-family: Geneva, Arial, Helvetica, sans-serif; font-size: x-small; }
    .style9 {font-size: x-small}
    -->
    </style>
    </head>

    <body>
    <div align="center"></div>
    <table width="800" border="0" cellspacing="2" cellpadding="2" >
    <tr>
    <td colspan="2"><img src="front%20copy.gif" width="1060" height="151"></td>
    </tr>
    <tr>
    <td width="210"><img src="user.png" width="29" height="35"></td>
    <td><span class="style1">Logout</span></td>
    </tr>
    <tr bgcolor="#a1eb5d">
    <td><div align="center" class="style2">Home</div></td>
    <td width="846" rowspan="7" valign="top"><div align="center" class="style3">
    <p>INPUT DATA MASTER OBAT </p>
    <form name="form1" method="post" action="">
    <table width="705" border="0" align="center">
    <tr>
    <td width="278"><span class="style4">Kode Barang :
    <input name="kode_barang" type="text" size="20">
    </span></td>
    <td width="417"><span class="style4">Harga / kemasan :
    <input type="text" name="h_kemasan">
    </span></td>
    </tr>
    <tr>
    <td><span class="style4">Nama Barang :
    <input type="text" name="nama_obat">
    </span></td>
    <td><span class="style4">PPN :
    <select name="ppn">
    <option value="-">none</option>
    <option value="10%">10%</option>
    </select>
    Nilai :
    <input type="text" name="nilai">
    </span></td>
    </tr>
    <tr>
    <td><span class="style4">Kategori :
    <select name="nama_kategori">
    <?php
    do {
    ?>
    <option value="<?php echo $row_kategori['nama_kategori']?>"><?php echo $row_kategori['nama_kategori']?></option>
    <?php
    } while ($row_kategori = mysql_fetch_assoc($kategori));
    $rows = mysql_num_rows($kategori);
    if($rows > 0) {
    mysql_data_seek($kategori, 0);
    $row_kategori = mysql_fetch_assoc($kategori);
    }
    ?>
    </select>
    </span></td>
    <td><span class="style4">Harga Setelah PPN :
    <input type="text" name="hs_ppn">
    </span></td>
    </tr>
    <tr>
    <td><span class="style4">Kemasan :
    <select name="kmsn">
    <option value="None">None</option>
    <?php
    do {
    ?>
    <option value="<?php echo $row_kategori['nama_kategori']?>"><?php echo $row_kategori['nama_kategori']?></option>
    <?php
    } while ($row_kategori = mysql_fetch_assoc($kategori));
    $rows = mysql_num_rows($kategori);
    if($rows > 0) {
    mysql_data_seek($kategori, 0);
    $row_kategori = mysql_fetch_assoc($kategori);
    }
    ?>
    </select>
    </span></td>
    <td><span class="style4">Harga Satuan Setelah PPN :
    <input type="text" name="hss_ppn">
    </span></td>
    </tr>
    <tr>
    <td><span class="style4">Isi :
    <input name="isi" type="text" size="10">
    Satuan :
    <select name="sat">
    <option value="AMP">AMP</option>
    <option value="TUBE">TUBE</option>
    <option value="BTL">BTL</option>
    <option value="TAB">TAB</option>
    <option value="KPL">KPL</option>
    </select>
    </span></td>
    <td><span class="style4">Stok :
    <input name="textfield" type="stol" size="12">
    </span></td>
    </tr>
    <tr>
    <td colspan="2"><div align="center">
    <input type="submit" name="Submit" value="SIMPAN">
    <input type="reset" name="Reset" value="HAPUS">
    </div></td>
    </tr>
    </table>
    <input type="hidden" name="id_barang" value="">
    </form>
    <p> </p>

    <table border="1">
    <tr>
    <td rowspan="2"><div align="center" class="style8">No.</div></td>
    <td rowspan="2"><div align="center" class="style8">Kode Barang </div></td>
    <td rowspan="2"><div align="center" class="style8">Nama Barang </div></td>
    <td rowspan="2"><div align="center" class="style8">Kategori</div></td>
    <td rowspan="2"><div align="center" class="style8">Kemasan </div></td>
    <td rowspan="2"><div align="center" class="style8">Isi</div></td>
    <td rowspan="2"><div align="center" class="style8">Satuan</div></td>
    <td rowspan="2"><div align="center" class="style8">Harga / kemasan</div></td>
    <td colspan="2"><div align="center"><span class="style4"><span class="style6"><span class="style7"><span class="style9">Keterangan</span></span></span></span></div></td>
    <td rowspan="2"><div align="center" class="style8">Harga + PPN </div></td>
    <td rowspan="2"><div align="center" class="style8">Harga Satuan + PPN </div></td>
    <td rowspan="2"><div align="center" class="style8">Stok</div></td>
    </tr>
    <tr>
    <td><div align="center" class="style8">PPN </div></td>
    <td><div align="center" class="style8">Nilai</div></td>
    </tr>
    <?php do { ?>
    <tr>
    <td><span class="style8"><?php echo $row_obat['id_barang']; ?></span></td>
    <td><span class="style8"><?php echo $row_obat['kode_barang']; ?></span></td>
    <td><span class="style8"><?php echo $row_obat['nama_obat']; ?></span></td>
    <td><span class="style8"><?php echo $row_obat['nama_kategori']; ?></span></td>
    <td><div align="center"><span class="style8"><?php echo $row_obat['kmsn']; ?></span></div></td>
    <td><div align="center"><span class="style8"><?php echo $row_obat['isi']; ?></span></div></td>
    <td><div align="center"><span class="style8"><?php echo $row_obat['sat']; ?></span></div></td>
    <td><div align="right"><span class="style8"><?php echo $row_obat['h_kemasan']; ?></span></div></td>
    <td><div align="center"><span class="style8"><?php echo $row_obat['ppn']; ?></span></div></td>
    <td><div align="right"><span class="style8"><?php echo $row_obat['nilai']; ?></span></div></td>
    <td><div align="right"><span class="style8"><?php echo $row_obat['hs_ppn']; ?></span></div></td>
    <td><div align="right"><span class="style8"><?php echo $row_obat['hss_ppn']; ?></span></div></td>
    <td><div align="center"><span class="style8"><?php echo $row_obat['stol']; ?></span></div></td>
    </tr>
    <?php } while ($row_obat = mysql_fetch_assoc($obat)); ?>
    </table>

    <table border="0" width="70%" align="center">
    <tr>
    <td width="19%" align="center"><div align="center">
    <?php if ($pageNum_obat > 0) { // Show if not first page ?>
    <span class="style9">">First
    <?php } // Show if not first page ?>
    </span></div></td>
    <td width="17%" align="center"><div align="center">
    <?php if ($pageNum_obat > 0) { // Show if not first page ?>
    <span class="style9">">Previous
    <?php } // Show if not first page ?>
    </span></div></td>
    <td width="37%"> <div align="center"><span class="style9"><?php echo ($startRow_obat + 1) ?> to <?php echo min($startRow_obat + $maxRows_obat, $totalRows_obat) ?> of <?php echo $totalRows_obat ?> </span></div></td>
    <td width="10%" align="center"><div align="center">
    <?php if ($pageNum_obat < $totalPages_obat) { // Show if not last page ?>
    <span class="style9">">Next
    <?php } // Show if not last page ?>
    </span></div></td>
    <td width="17%" align="center"><div align="center">
    <?php if ($pageNum_obat < $totalPages_obat) { // Show if not last page ?>
    <span class="style9">">Last
    <?php } // Show if not last page ?></span></div></td>
    </tr>
    </table>
    </div></td>
    </tr>
    <tr bgcolor="#a1eb5d">
    <td><div align="center" class="style2">Data Pasien </div></td>
    </tr>
    <tr bgcolor="#a1eb5d">
    <td><div align="center" class="style2">Master Obat </div></td>
    </tr>
    <tr bgcolor="#a1eb5d">
    <td><div align="center" class="style2">Resep</div></td>
    </tr>
    <tr bgcolor="#a1eb5d">
    <td><div align="center" class="style2">Supplier</div></td>
    </tr>
    <tr bgcolor="#a1eb5d">
    <td><div align="center" class="style2">Pembelian</div></td>
    </tr>
    <tr bgcolor="#a1eb5d">
    <td><div align="center" class="style2">Penjualan</div></td>
    </tr>
    <tr bgcolor="#a1eb5d" c>
    <td colspan="2"> </td>
    </tr>
    </table>
    </body>
    </html>
    <?php
    mysql_free_result($obat);

    mysql_free_result($kategori);
    ?>

  2. Andrei Olsen
    Member
    Posted 1 year ago #

    Typically a result of a missing }. Did you close your rupiah function?

  3. heriodk77
    Member
    Posted 1 year ago #

    ok thank's

    but i still have problem, can you help me to fix

    Notice: Undefined index: kode_barang in C:\xampp\htdocs\apotik1\Untitled-1.php on line 8

    Notice: Undefined index: nama_obat in C:\xampp\htdocs\apotik1\Untitled-1.php on line 9

    Notice: Undefined index: nama_kategori in C:\xampp\htdocs\apotik1\Untitled-1.php on line 10

    Notice: Undefined index: kmsn in C:\xampp\htdocs\apotik1\Untitled-1.php on line 11

    Notice: Undefined index: isi in C:\xampp\htdocs\apotik1\Untitled-1.php on line 12

    Notice: Undefined index: sat in C:\xampp\htdocs\apotik1\Untitled-1.php on line 13

    Notice: Undefined index: h_kemasan in C:\xampp\htdocs\apotik1\Untitled-1.php on line 14

    Notice: Undefined index: ppn in C:\xampp\htdocs\apotik1\Untitled-1.php on line 15

    Warning: Division by zero in C:\xampp\htdocs\apotik1\Untitled-1.php on line 16

    Warning: Division by zero in C:\xampp\htdocs\apotik1\Untitled-1.php on line 18

    Notice: Undefined index: stol in C:\xampp\htdocs\apotik1\Untitled-1.php on line 19

    Notice: Undefined index: nama_obat in C:\xampp\htdocs\apotik1\Untitled-1.php on line 29

  4. Andrei Olsen
    Member
    Posted 1 year ago #

    These are warnings. You can hide them by adding
    error_reporting(E_ALL ^ E_NOTICE);
    to php.ini or .htaccess

    But if you really want to fix these you should check the values are set and are not NULL with isset(), e.g.
    if (isset($_POST['kode_barang'])){ $kode = $_POST['kode_barang']; }

    Also, maybe set a default value for variable with else statement if you're using the variable later in the code.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.