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); } ?> 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. Link to comment https://forums.phpfreaks.com/topic/154738-solved-syntax-error/#findComment-813733 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.