jamcoupe Posted August 11, 2009 Share Posted August 11, 2009 I am just trying to make a simple news script. I am trying to display all the news posts and their comments underneath them. Any ideas why I am getting: Parse error: syntax error, unexpected $end in /Applications/MAMP/htdocs/jstar/test.php on line 69 Heres my code: <?php require("constants.php"); $connection = mysql_connect(DB_SERVER,DB_USER,DB_PASS); query_check($connection); $db_select = mysql_select_db(DB_NAME, $connection); query_check($db_select); ?> <?php function query_check($check) { if(!$check) { die ("OOOPS: " . mysql_error()); } } function get_news() { global $connection; $query = ("SELECT * FROM news ORDER BY id ASC"); query_check($query); $news = mysql_query($query, $connection); return $news; } function get_comments($id) { global $connection; $query = ("SELECT * FROM comments WHERE newsid = {$id} ORDER BY id ASC"); query_check($query); $comments = mysql_query($query, $connection); return $comments; } //This will enable function get_news_id($news_id) { global $connection; $query = ("SELECT * FROM news WHERE id={$news_id} LIMIT 1"); $query = mysql_query($query, $connection); query_check($query); if($id = mysql_fetch_array($query)) { return $id; } else { return NULL; } } ?> <?php $get_news = get_news(); while ($news = mysql_fetch_array($get_news)) { echo "{$news['title']}<br />"; $get_comments = get_comments($news['id']); while ($comments = mysql_fetch_array($get_comments)) { echo "{$comments['comment]}<br />"; } } ?> <?php if(isset($connection)) { mysql_close($connection); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/169712-solved-stuck-at-an-unexpected-end/ Share on other sites More sharing options...
abazoskib Posted August 11, 2009 Share Posted August 11, 2009 i dont see any syntax errors in what you posted, well as far as php -l is concerned. Quote Link to comment https://forums.phpfreaks.com/topic/169712-solved-stuck-at-an-unexpected-end/#findComment-895345 Share on other sites More sharing options...
jarvis Posted August 11, 2009 Share Posted August 11, 2009 Is that test.php or does test.php call in the above? Quote Link to comment https://forums.phpfreaks.com/topic/169712-solved-stuck-at-an-unexpected-end/#findComment-895440 Share on other sites More sharing options...
jamcoupe Posted August 11, 2009 Author Share Posted August 11, 2009 The script is test.php sorry I didnt say in the first post Quote Link to comment https://forums.phpfreaks.com/topic/169712-solved-stuck-at-an-unexpected-end/#findComment-895493 Share on other sites More sharing options...
wildteen88 Posted August 11, 2009 Share Posted August 11, 2009 There is no problems with that script. Your code works fine. However I do not see the point in doing <?php // some php code here ?> <?php // some more php code here ?> If you're not going to put anything between the code blocks then there is no need to go out of php and then immediately back in to php. Quote Link to comment https://forums.phpfreaks.com/topic/169712-solved-stuck-at-an-unexpected-end/#findComment-895536 Share on other sites More sharing options...
Mark Baker Posted August 11, 2009 Share Posted August 11, 2009 Is this the entire script, or just the PHP part... have you stripped anything out from between the ?> and <?php Quote Link to comment https://forums.phpfreaks.com/topic/169712-solved-stuck-at-an-unexpected-end/#findComment-895540 Share on other sites More sharing options...
jamcoupe Posted August 11, 2009 Author Share Posted August 11, 2009 Ahhhhhh I figured our the problem... It was the line. echo "{$comments[comment]}<br />"; Should have been. echo "{$comments['comment']}<br />"; and that was the entire script. Quote Link to comment https://forums.phpfreaks.com/topic/169712-solved-stuck-at-an-unexpected-end/#findComment-895542 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.