@requinix I created a new pdo Object, and fed in details of db like in config file.
It doesnt throw the error anymore but then again when i run it it doesnt add given data lol.
Sorry, Im php noob. im normally a java dev just learning this is stressful.
class UserQuery {
public function Adduser($id,$username,$email,$password){
$dsn = "mysql:dbname=test;host=127.0.0.1:3306";
$user = "root"; $passwd = "2194";
$pdo = new PDO($dsn, $user, $passwd);
$sql =("INSERT INTO test.user (id, username, email, password) VALUES ('$id', '$username', '$email',$password)");
$pdo->exec($sql);
} }