I am trying to use mysqli in object orientated way, this is the code:
class conect {
function populate( ) {
while ($row = $this->result->fetch_object()) { $this->data[] = $row; }
$this->result->close();
}
function conect( ) {
$mysqli = new mysqli('localhost', 'root', 'root', 'todo');
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
};
}
function register($name, $email, $password ) {
$mysqli->query("INSERT INTO user (name, email, password)
VALUES ('$name', '$email', '$password')");
}
}
The register function is the problem, if I add that query in the conect() function it does work, but as it id does not work,no error is displayed
I have been trying to learn object orientated php and mysqli. I have managed to use the above style to create a dynamic portfolio, but this is the first time I tried to write to DB so I dont know whats the problem
Hope you can help
Thanks
you don’t display any errors, so, no wonder there are no errors displayed.
but, to let you know, your code has nothing to do with mysqli and oop anyway.