divinedesigns1 Posted May 27, 2012 Share Posted May 27, 2012 can someone help me understand this error, i made sure all the braces are matched up but im still getting that error this is the error Parse error: syntax error, unexpected T_ELSE in C:\wamp\www\news\index.php on line 97 and this is the code<?phpinclude_once(news/MyConnect.php);$query = "SELECT title DATE_FORMAT(date, '%M %d') as sd FROM news ORDER BY date DESC";$result = mysqli_query($con, $query);if(isset($_GET['id'])){ $id = $_GET['id'];}else{ if($result){ while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){ echo '<div class="in_news"><div class="tie">' . $row['title'] . '<a href="news.php?$id=id">..more</div>' . '</div>' . '<div class="sd">' . $row['sd'] . '</div></div>' . '<br />'; }else{ echo 'no post'; } }}?> btw the <a href="news.php?$id=id">..more</div> is a test, im trying to use to get something by the id in the mysql anyway, i each google and it said the braces are unmatched so i rewrote the script and make sure i ended each brace when i open it but still im getting this error. Link to comment Share on other sites More sharing options...
divinedesigns1 Posted May 27, 2012 Author Share Posted May 27, 2012 error fixed Link to comment Share on other sites More sharing options...
niche Posted May 27, 2012 Share Posted May 27, 2012 Where was it? Link to comment Share on other sites More sharing options...
Ingolme Posted May 27, 2012 Share Posted May 27, 2012 It's clearly the unclosed while() loop that caused the problem. Link to comment Share on other sites More sharing options...
niche Posted May 27, 2012 Share Posted May 27, 2012 Please show me. I still don't see it and that bothers me. Link to comment Share on other sites More sharing options...
Ingolme Posted May 27, 2012 Share Posted May 27, 2012 It's this structure: while() {...} else {...} Link to comment Share on other sites More sharing options...
niche Posted May 27, 2012 Share Posted May 27, 2012 That's the structure I was looking for and found in the question. What do you see, that I don't? Link to comment Share on other sites More sharing options...
Ingolme Posted May 27, 2012 Share Posted May 27, 2012 The else keyword only can be used on an if() statement, not on a while() statement. Link to comment Share on other sites More sharing options...
thescientist Posted May 27, 2012 Share Posted May 27, 2012 That's the structure I was looking for and found in the question. What do you see, that I don't? http://www.w3schools...php_if_else.asphttp://www.w3schools...php_looping.asp while is a looping structure, likefor($i = 0, $l = count($someArray); $i < $l; $i += 1){ echo $i;}; if/else is a conditional structure. They are not interchangeable. Link to comment Share on other sites More sharing options...
niche Posted May 27, 2012 Share Posted May 27, 2012 Dooh! What doesn't kill me makes me stronger. Thanks for accomodating me Ingolme and you to thescientist.. I'm confident I wouldn't have made that mistake, but it's interesting that I didn't catch it, at all, in someone else. Hmm. Link to comment Share on other sites More sharing options...
divinedesigns1 Posted May 27, 2012 Author Share Posted May 27, 2012 oh you guys already told him, sorry niche, was dealing with another problem im having, but yea that was the problem, i just moved the other else down and it worked Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.