0

I have been stuck on my code for a while and has tried googling but cannot find whats the problem with my code, can someone help me? It returns the error "Parse error: syntax error, unexpected end of file on line 35".

<?php
require_once('template.php');
include ('login.php');
$content = '<h1>Products</h1>';
$query   = <<<END
SELECT * FROM products
ORDER BY created_at DESC
END;
$res     = $mysqli->query($query);

if (isset($_SESSION['userId']) and ($res->num_rows > 0)) {
    while ($row = $res->fetch_object()) {
        $content .= <<<END
        {$row->name} |
            {$row->price}<br>
            <a href="product_details.php?id={$row->id}">Description</a>| 
            <a href="delete_product.php?id={$row->id}" onclick="return confirm('Are you sure?')"> 
            Remove product</a>|
            <a href="edit_product.php?id={$row->id}">Edit product</a><br>
            </hr>
END;
    }
} 
elseif (($res->num_rows > 0)) {
    while ($row = $res->fetch_object()) {
        $content .= <<<END
            {$row->name}|
                {$row->price}<br>
                <a href="product_details.php?id={$row->id}">Description</a><br>
END; 
    }
}
echo $navigation;
echo $content;
?>
0

1 Answer 1

1

You have added space after HEREDOC tag ending.

On line 30:

END; 

Should be only (without space after semicolon):

END;

Detailed answer: https://stackoverflow.com/a/61127019/7082164

I would not recommend using HEREDOC, it's not much readable.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.