I am using objects in php. I have an object to connect to database server $con object and $opt (operation) object to send query to database server, till now there is no problem, the problem is that I defined the $con object as static and I defined it in $opt object as it shows in below code
class operations{
public static $con = null;
public function __construct($tableName = null){
// Creating an object of connection
self::$con = new config();
self::$con = self::$con->getConnection();
}
}
So when I want to call the $con object there is no problem
mysql_query($query,$opt::$con) or die (mysql_error());
but on server it appears with this error
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM
Your scope resolution is unexpected, that means that you use it in a bad context.
When do you use “::”? After
selfstatic, classname or a string representing the name of a class :Instead of that, you use it over ans instance of your class and php does not like it.
You should use
mysql_query($query,operations::$con) or die (mysql_error());