This question already has answers here:
</div>
</div>
<div class="grid--cell mb0 mt4">
<a href="/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them" dir="ltr">PHP parse/syntax errors; and how to solve them</a>
<span class="question-originals-answer-count">
(18 answers)
</span>
</div>
<div class="grid--cell mb0 mt4">
<a href="/questions/22662488/mysqli-fetch-assoc-expects-parameter-call-to-a-member-function-bind-param" dir="ltr">mysqli_fetch_assoc() expects parameter / Call to a member function bind_param() errors. How to get the actual mysql error and fix it?</a>
<span class="question-originals-answer-count">
(1 answer)
</span>
</div>
<div class="grid--cell mb0 mt4">
<a href="/questions/24028697/how-to-fetch-data-in-php-with-mysqli" dir="ltr">How to fetch data in PHP with MySQLi?</a>
<span class="question-originals-answer-count">
(3 answers)
</span>
</div>
<div class="grid--cell mb0 mt4">
<a href="/questions/28903302/mysqli-connection-and-query" dir="ltr">mysqli connection and query</a>
<span class="question-originals-answer-count">
(2 answers)
</span>
</div>
<div class="grid--cell mb0 mt8">Closed <span title="2017-12-03 13:40:15Z" class="relativetime">2 years ago</span>.</div>
</div>
</aside>
I got this syntax error saying there is a mistake on line 4, but I can't seem to find it..can you help me?
Parse error: syntax error, unexpected ':', expecting ',' or ')' in C:\XAMPP\htdocs\projekt\ajax.php on line 4
My code:
<?php
if (isset($_POST["key"])) {
$conn = new mysqli(host:"localhost", username:"root", passwd:"", dbname:"serije_bp");
$name = $conn->real_escape_string($_POST["naziv"]);
$opis = $conn->real_escape_string($_POST["opis"]);
$ocjena = $conn->real_escape_string($_POST["ocjena"]);
if ($_POST["key"] == "dodajNovu") {
$sql = $conn->query(query: "SELECT id FROM serije WHERE naziv = '$naziv'");
if ($sql->num_rows > 0)
exit("TV serija je vec unesena!");
else {
$conn->query(query: "INSERT INTO serija (naziv, opis, ocjena)
VALUES ('$naziv', '$opis', '$ocjena')");
exit("TV serija je uspjesno unesena!");
}
}
}
?>
</div>