Thanks for your reply.
You are right, i didn't have an active connection, i tried your way and it works great and more effectively , i will use it from now on, but it's still not clear for me why do i have to return $con. (I know i must do it because i don't have an active connection but i don't get why, i don't know what $con is equal to or why is it important)
So the way i'm seeing this is that without returning $con like this:
class Connect
{
public static function con()
{
$con=mysql_connect("localhost","root","");// Connects to DB???
mysql_query("SET NAMES 'utf8'"); // Sets charset to UTF8
mysql_select_db("blog"); // Selects the DB
}
}
And when running this:
mysql_query($somequery,Connect::con());// Entire method con() is run? or is it just passing the returned value if any? whatever that is
Wouldn't php run all 3 lines inside the method/function con() and start a new connection when the the first line is run? with no need to return anything.
Thanks for your time.