I’m new at object oriented programming with php. I have a problem. I wrote a code but that does not work. I know it’s easy yet I wonder what’s wrong with it. I take the following error :

<?php
class connectDB
{
$connection;
$server= "localhost";
$userName = "root";
$password = "";
$select;
$dbName = "profiles";
public function connect()
{
$connection = mysql_connect($server,$userName,$password);
$select = mysql_select_db($dbName,$connection);
}
public function query()
{
$result = mysql_query($query);
if (!$result) {
echo 'Bağlantı Hatası: ' . mysql_error();
exit;
}
}
public function end()
{
mysql_free_result($connection);
}
}
?>
When i try to use it in another file , i take this error now 🙁

A class is not supposed to do something (yes, it does something through methods), it is primarily there to represent something – an object of the real world. The “thing” being represented is the one doing something.
The name
suggests otherwise.
You should learn some OOP principles from a book before attempting to “just group functions”. That’s not what classes are for.
See: https://stackoverflow.com/questions/249835/book-recommendation-for-learning-good-php-oop
In the end you would have either a class
Connectionor a classDatabase.And, since you’ve joined the “OOP club”, you should use PDO.