Postingan lainnya
Kelas Premium!
Belajar bikin website dari nol sekarang
Gunakan kupon "lebihcepat" untuk diskon 25%!
Mengeluarkan Data Yang ada di database
Halo, Saya ingin membuat website networking untuk tugas dimana user bisa menginput, lalu disimpan ke database dan langsung menampilkan data yang diinputkan user di bawahnya.. nah, saat saya mencoba membuatnya, terjadi error Parse error: syntax error, unexpected 'while' (T_WHILE) in C:\xampp\htdocs\ProjectPrognet12\timeline.php on line 66, Kira" Solusinya Bagaimana ya? Terima Kasih
<?php
require_once("auth.php");
//include "koneksi.php";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="icon" type="image/png" href="Assets/icon.png">
<link rel="stylesheet" type="text/css" href="Assets/timeline.css">
<title>Timeline HeadBook</title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
</head>
<body class="bg-light">
<div class="container mt-5">
<div class="row">
<div class="col-md-4">
<div class="card">
<div class="card-body text-center">
<img class="img img-responsive rounded-circle mb-3" width="160" src="Assets/<?php echo $_SESSION['user'][7] ?>" />
<h3><?php echo $_SESSION['user'][1]." ".$_SESSION['user'][2] ?></h3>
<p><?php echo $_SESSION['user'][3] ?></p>
<p><a href="logout.php">Logout</a></p>
</div>
</div>
</div>
<div class="col-md-8">
<form action="" method="post" >
<div class="form-group">
<textarea type="text" name="Nama" style="display:none;"><?php echo $_SESSION['user'][3] ?> </textarea>
<textarea class="form-control" placeholder="Apa yang kamu pikirkan?" name="status"></textarea>
<br>
<button type="submit" class="btn btn-danger" name="tombol">Bagikan</button>
</div>
<?php
require_once("config.php");
if(isset($_POST['tombol'])){
$email = $_REQUEST['Nama'];
$status = $_REQUEST['status'];
$conn = mysqli_connect($db_host, $db_user, $db_pass, $db_name) or die ("Koneksi gagal");
$mysqli = "INSERT INTO timeline (Email, Status) VALUES ('$email', '$status')";
$result = mysqli_query($conn, $mysqli);
//$rows = $result->fetch(PDO::FETCH_NUM);
//$_SESSION['user1'] = $rows;
//echo "<script>history.back()</script>";
}
$select = mysqli_query($conn, "SELECT * FROM timeline")
while($stat = mysqli_fetch_array($result)){
echo "";
}
mysqli_close($conn);
?>
</form>
</div>
</body>
</html>
2 Jawaban:
Jawaban Terpilih
kalau kamu ketemu error "syntax error, unexpected 'while' di PHP" kemungkinan ada cara penulisan, kali ini kamu lupa titik koma $select = mysqli_query($conn, "SELECT * FROM timeline") //titik koma disini (;)
lha itu..
waktu select pake $select. kok while nya pake $result.