OO code not working :(
Posted: Tue Oct 28, 2008 6:54 am
I just started objected oriented programming. Wrote first code today but it's creating problem... Here's the code
This code is giving error. The error is "Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in J:\index.php on line 30".. The error is in creating the instance... I might have done some foolish mistake; I really want to know what's the prob... 
Code: Select all
class sqlize
{
var $host="localhost";
var $user="root";
var $password="";
function sqlize($databaseName)
{
global $con;
$con=mysql_connect($this->host,$this->user,$this->pass);
$que="mysql_select_db($databaseName,$con)";
if (!$con)
{
echo "Couldn't connect : ".mysql_error();
}
else
{
if(!$que)
{
mysql_query("CREATE DATABASE $name",$con);
}
}
function close()
{
mysql_close($con);
}
}
$demo = new sqlize();