Jump to content

Can someone help with error


divinedesigns1

Recommended Posts

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

Please show me. I still don't see it and that bothers me.

Link to comment
Share on other sites

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

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, like
for($i = 0, $l = count($someArray); $i < $l; $i += 1){  echo $i;};

if/else is a conditional structure. They are not interchangeable.

Edited by thescientist
  • Like 1
Link to comment
Share on other sites

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.

Edited by niche
Link to comment
Share on other sites

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...