jenslekman Posted June 7, 2010 Share Posted June 7, 2010 howdy, i have the following error in my browser. Parse error: parse error in C:\Wamp Server\wamp\www\modern_cms\_class\cms_class.php on line 23 the else statement is screwing it all up... here is my cms_class.php <?php class modernCMS { var $host; var $username; var $password; var $db; function connect() { $con = mysql_connect($this->host, $this->username, $this->password) or die(mysql_error()); mysql_select_db($this->db, $con) or die(mysql_error()); } function get_content($id = ''){ if($id !=''){ $id = mysql_real_escape_string($id); $sql = "SELECT * FROM cms_content WHERE id = '$id'"; else: $sql = "SELECT * FROM cms_content ORDER BY id DESC"; endif; } $res = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_assoc($res)){ echo '<h1><a href="index.php?id=' . $row['id'] . '">' . $row['title'] . '</a></h1>'; echo '<p>' . $row['body'] . '</p>'; } } }//Ends our class ?> hope you can assist me Quote Link to comment https://forums.phpfreaks.com/topic/204050-error-from-else-statement-is-showing-up/ Share on other sites More sharing options...
trq Posted June 7, 2010 Share Posted June 7, 2010 You can't mix alternate and traditional syntax. else: should be } else { Quote Link to comment https://forums.phpfreaks.com/topic/204050-error-from-else-statement-is-showing-up/#findComment-1068777 Share on other sites More sharing options...
jenslekman Posted June 7, 2010 Author Share Posted June 7, 2010 thanks for reply thorpe, i did what yo said but now am getting a 'T_FUNCTION' error Parse error: parse error, expecting `T_FUNCTION' in C:\Wamp Server\wamp\www\modern_cms\_class\cms_class.php on line 23 Quote Link to comment https://forums.phpfreaks.com/topic/204050-error-from-else-statement-is-showing-up/#findComment-1068779 Share on other sites More sharing options...
kratsg Posted June 7, 2010 Share Posted June 7, 2010 I believe you need to replace your endif; with a closing brace "}". thanks for reply thorpe, i did what yo said but now am getting a 'T_FUNCTION' error Parse error: parse error, expecting `T_FUNCTION' in C:\Wamp Server\wamp\www\modern_cms\_class\cms_class.php on line 23 Quote Link to comment https://forums.phpfreaks.com/topic/204050-error-from-else-statement-is-showing-up/#findComment-1068780 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.