I have a problem. When I use global variables in my php code, my server doesn't show any html code at all. If I comment out the global variable, my html page works just fine! Am I doing something wrong here?
php file:
class DBConnect{
// If I comment this out, the HTML shows
global $con;
function connectDB() {
$user = "bstokni_basurin";
$pass = "basurin";
$database = "basurin";
$host = "localhost";
$this->$con = mysql_connect($host, $user, $pass) or die(mysql_error());
echo "Connected to MySQL </br>";
echo $con;
}
function closeDB() {
mysql_close($con);
echo $con;
echo "MySQL closed";
}
}
html file:
<!-- Left colon -->
<div id="leftCol">
<p>Her kemur ein menu at standa</p>
<?
$menuObj = new DBConnect();
$menuObj->connectDB();
?>
</div>
What am I doing wrong here?
error_reporting(E_ALL); ini_set('display_errors', '1');