I am working on homework assignment that requires making of a simple news site with the ability to list news from different categories, to allow logged in users to comment articles and delete them.
I managed to do all of the mentioned except deletion. I get this error message "Parse error: syntax error, unexpected 'if' (T_IF) in C:......\delete.php on line 4".
Here is my show_comments.php file code:
<?php
require_once("konektor.php");
$article_id = $_GET['id'];
$qCommentShow = "
SELECT
`komentari`.`id` as `kom_id`,
`komentari`.`komentar`,
`komentari`.`korisnik_id`,
`komentari`.`sajt_id`,
`korisnici`.`username`
FROM `komentari`, `korisnici` WHERE `sajt_id` = $article_id
GROUP BY `komentari`.`id`
ORDER BY `komentari`.`id` DESC ";
$komentarPrikazi = $konektor->query($qCommentShow);
echo "<h3>Komentari korisnika</h3>";
$sviKomentari = $komentarPrikazi->fetchAll(PDO::FETCH_OBJ);
foreach($sviKomentari as $b){
echo "<div style='margin:30px 0px;'>
<p>Ime: ". $b->username ."</p><p>Komentar:</p><textarea> ". $b->komentar ."</textarea><br>
</div>";
echo "<a href ='index.php?opcija=delete&id=". $b->kom_id ."'>Izbrisi komentar</a>";
echo "<hr>";
}?>
and my delete.php file code:
<?php
require_once("konektor.php")
if (isset($_GET['id'])){
$qBrisi = "
DELETE FROM `komentari` WHERE `id` = '" .$_GET['id']. "'; AND `korisnik_id` =
'" .$_SESSION['id']. "';
";
$komentarBrisi= $konektor->query($qBrisi)
}
else {
echo "error";
include ("location: kategorije.php");
}
?>
If required, I can also post my category.php code where I list all the categories with established dynamic paging.
I have tried looking around the internet what I could be doing wrong but everywhere I checked, the code is almost identical to mine so I am really scratching my head here what I am doing wrong.
P.S I know my code is still unfinished and vulnerable to attacks but right now, I have to make a really basic and functional version of the site.