<?php
include ("../dataconnection.php");
if(isset($_GET['sub']))
{
if(isset($_POST['name']))
$name = $_POST['name'];
if(isset($_POST['content']));
$content = $_POST['content'];
$query = "INSERT INTO testimonial (testi_name, testi_content) VALUES ('$name', '$content')";
$result = mysqli_query($connect, $query);
?>
<script>
alert("Your review has been submitted!");
</script>
<?php
header("Refresh:0");
}
$getTesti = "SELECT * FROM testimonial ORDER BY testi_name ASC";
$result = mysqli_query($connect, $getTesti) or die(mysqli_error($connect));
$row = mysqli_fetch_assoc($result);
?>
<?php foreach($row as $review):?>
<div class="box">
<h3><?php htmlspecialchars($review['testi_name'], ENT_QUOTES); ?></h3>
<?php htmlspecialchars($review['testi_content'], ENT_QUOTES); ?>
</div>
<?php endforeach; ?>
Hi I'm having issue where for the second coding it says Illegal string offset 'testi_name'. I tried reading others questions that have been solved but I still couldn't understand. I get the 'testi_name' from my sql. Please tell me what is the problem as I'm a beginner in php. Thank you, your help is greatly appreciated.
It even loop it 3 times eventhough i only have 1 row in my sql [1]: https://i.stack.imgur.com/C8hhd.png