blog_read issue

Ask about a PHP problem here.
Post Reply
guitardude211
Posts: 12
Joined: Tue Dec 06, 2011 6:55 pm

blog_read issue

Post by guitardude211 »

Hey everyone,

I am getting an error "Parse error: syntax error, unexpected ';' in blog_read.php on line 7"

when the code looks correct to me..Here is the code:

blog_read.php
[syntax=php]<?php

include('core/init.inc.php');

if (isset($_GET['pid'], $_POST['user'], $_POST['body'])) {
if (add_comment($_GET['pid'], $_POST['user'], $_POST['body']))(
header("Location: blog_read.php?pid={$_GET['pid']}");
)else{
header('Location: blog_list.php');
}

die();
}

?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Blog</title>
</head>
<body>
<div>
<?php

if (isset($_GET['pid']) === false || valid_pid($_GET['pid']) === false) {
echo 'Invalid post ID.';
}else{
$post = get_post($_GET['pid']);

?>
<h2><?php echo $post['title']; ?></h2>
<h4>By <?php echo $post['user']; ?> on <?php echo $post['date']; ?>(<?php echo count($post['comments']); ?> comments)</h4>

<hr />

<p><?php echo $post['body']; ?></p>

<hr />
<?php

foreach ($post['comments'] as $comment){
?>
<p><?php echo $comment['body']; ?></p>
<h4>By <?php echo $comment['user']; ?> on <?php echo $comment['date']; ?></h4>
<hr />
<?php
}

?>
<form action="" method="post">
<p>
<label for="user">Name</label>
<input type="text" name="user" id="user" />
</p>
<p>
<textarea name="body" rows="20" col="60"></textarea>
</p>
<p>
<input type="submit" value="Add Comment!" />
</p>
</form>
<?php
}

?>
</div>
</body>
</html>[/syntax]

Thanks for anyone who can probably help this small issue :)
Jaami
Posts: 38
Joined: Wed Nov 23, 2011 11:22 pm
Location: GER

Re: blog_read issue

Post by Jaami »

your using brackets instead of curly brackets in your second if statement.
guitardude211
Posts: 12
Joined: Tue Dec 06, 2011 6:55 pm

Re: blog_read issue

Post by guitardude211 »

Shouldn't it be brackets though since that is what shows in the video tutorial in video part 6?
Jaami
Posts: 38
Joined: Wed Nov 23, 2011 11:22 pm
Location: GER

Re: blog_read issue

Post by Jaami »

nope, i just checked the vids again and it showing up also with curly brackets..
loops are always opening and closing with curly brackets:
if(expression){
}
else{
}

this: [syntax=php]$_POST['body']))(
header("Location: blog_read.php?pid={$_GET['pid']}");
)else{[/syntax]

should be this:
[syntax=php]$_POST['body'])){
header("Location: blog_read.php?pid={$_GET['pid']}");
}else{[/syntax]
guitardude211
Posts: 12
Joined: Tue Dec 06, 2011 6:55 pm

Re: blog_read issue

Post by guitardude211 »

I've got it working!! Thanks for everyone's help and patience!! :)
Post Reply