phpjsonparse-errorphp-parse-error

PHP - Error=> T_CONSTANT_ENCAPSED_STRING


I am generating JSON feed and getting syntax error, unexpected ''Venue'' (T_CONSTANT_ENCAPSED_STRING), expecting ')' in line 25 All names ad fields are correct in database. The code I am using is here

<?php
$servername = "******";
$username = "******";
$password = "******";
$dbname = "******";


// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "select id ,Title , Description , Venue , Date from lodhievent";
$result = $conn->query($sql);
$values = array();
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {

    $values['data'][] = array(
        'id'=>$row['id'],
        'Title'=>$row['Title'],
        'Description'=>$row['Description']
        'Venue'=>$row['Venue']
        'Date'=>$row['Date']
    );

}


header('Content-Type: application/json;charset=utf-8');
echo json_encode($values ,JSON_PRETTY_PRINT);

} else {
$values = array(
    'error'=>'No results found'
);

}
$conn->close();
?>

Solution

  • You forgot commas on the first two lines here:

    'Description'=>$row['Description'],
    'Venue'=>$row['Venue'],
    'Date'=>$row['Date']