Parse error: syntax error, unexpected ';' in C:\xampp\htdocs\Website\classes\connect.php on line 29 [duplicate]
<?php
class Database
{
private $host = "localhost";
private $username = "root";
private $password = "root";
private $db = "site_db";
function connect()
{
$connection = mysqli_connect($this->host,$this->username,$this->password,$this->db);
return $connection;
}
function read($query)
{
$conn = $this->connect();
$result = mysqli_query($conn,$query);
if(!$result)
{
return false;
}
else
(
$data = false;
while($row = mysqli_fetch_assoc($result))
{
$data[] = $row;
}
return $data;
)
}
function save($query)
{
$conn = $this->connect();
$result = mysqli_query($conn,$query);
if(!$result)
{
return false;
}else
(
return true;
)
}
}
?>
line 29 is $data = false; if I remove the semicolon the error will read
Parse error: syntax error, unexpected 'while' (T_WHILE) in C:\xampp\htdocs\Website\classes\connect.php on line 30
I have followed the code in the tutorial to a T. I don't understand what I'm doing to throw this error. Help is much appreciated. Thanks.
source https://stackoverflow.com/questions/68199753/parse-error-syntax-error-unexpected-in-c-xampp-htdocs-website-classes-con
Comments
Post a Comment