Undefined variable: return line 38
that line is :
echo $return;
Below is a look at my full code.
<?php
class cms {
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'";
$return = '<a href="index.php">Go Back?</a>';
else:
$sql = "SELECT * FROM cms_content ORDER BY id DESC";
endif;
$res = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($res) != 0):
while($row = mysql_fetch_assoc($res)) {
echo '<h1><a href="index.php?id=' . $row['id'] .'">' . $row['title'] .'</a></h1>';
echo '<p>' . $row['body'] . '</p>';
}
else:
echo '<p> Sorry! This Page doesn\'t exist!</p>';
endif;
echo $return;
}
}//Ends our class
?>