0

I'm attempting to create a unique URL for each event but i'm getting a syntax error, do you know what it is?

echo '<div class="event-list">' . $row['eventname'] . '<p>' . $row['eventdate'] . '<p>' . 
'<img class="events" src="' . $row['eventimage'] .'"alt="" />' . "<a 
href='event.php?eventid=" . $row('eventID'] . "'>" . $row['eventname'] . "</a>" . 
'</div>';
1
  • 3
    1. What is the syntax error? 2. You shouldn't be echoing out HTML like this. PHP is an embedded language. Take advantage of it. Commented Dec 27, 2013 at 15:17

3 Answers 3

3

$row('eventID']

That ( should be a [

You should use an editor with syntax highlighting, and in the future if you need help with an error, POST THE ERROR.

This is a good time to use HEREDOC syntax. Also indent and space your code. If you can't even read it, there's a problem.

<?php
$str = <<<STRING
<div class="event-list">{$row['eventname']}
    <p>{$row['eventdate']}<p>
    <img class="events" src="{$row['eventimage']}" alt="" />
    <a href="event.php?eventid={$row['eventID']}">{$row['eventname']}</a>
 </div>
STRING;

echo $str;
Sign up to request clarification or add additional context in comments.

1 Comment

Hi, thanks for you help. i'm new to php - can you recommend an editor with syntax highlighting? I'm using dreamweaver and it only tells me the line that the error is on?
1

A syntax error isn't really a coding issue, yet I'm prepared to take a punt that the error read something like unexpected '('
That's because you have this typo:

$row('eventID']

Which should've been

$row['eventID']//square bracked

Please note: SO isn't a debugger service. Debugging is something you have to learn if you want to code

Comments

0

A simpler way, and nice indented HTML :

<div class="event-list">
    <?php echo $row['eventname'] ?>
    <p>
        <?php echo $row['eventdate'] ?>
    <p>
    <img class="events" src="<?php echo $row['eventimage'] ?>" alt="" />
    <a href="event.php?eventid=<?php echo $row['eventID'] ?>" > <?php echo $row['eventname'] ?></a>
</div>

1 Comment

even simpler would've been to use <?= $row['eventimage'] ?> :-}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.