Bopo Posted April 19, 2009 Share Posted April 19, 2009 Hi I should really be able to see where it's going wrong, but I'm having one of those moments where I just can't figure it out Parse error: syntax error, unexpected T_ELSE <?php $sql = "SELECT * FROM months where month = '$storemonth' AND year = '$storeyear'"; $query = mysql_query($sql, $connect); while($row = mysql_fetch_assoc($query)){ $month = $row['month']; $year = $row['year']; } else { //this is the line that is being highlighted. $sql = "INSERT INTO months (month, year) VALUES ('$storemonth', '$storeyear')"; if(!mysql_query($sql, $connect)) { die('Error' . mysql_error()); } mysql_close($connect); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/154738-solved-syntax-error/ Share on other sites More sharing options...
wildteen88 Posted April 19, 2009 Share Posted April 19, 2009 You have have an else statement directly after your while loop. You can only use else statements after an if statement. Quote Link to comment https://forums.phpfreaks.com/topic/154738-solved-syntax-error/#findComment-813733 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.