I'm creating a php class what is able to handle my query's and db connections.
I've played around with it for a while and did some research, now I've created m When I use the class for something to handle it does not commit, but I'm not able to see why it doesn't I don't get any error's and my mysqli error handling is correct.
does anyone have a idea what's wrong with my script?
sql class:
class sql{
function convertArrayReferences($arr){
$refs = array();
foreach($arr as $key => $value)
$refs[$key] = &$arr[$key];
return $refs;
}
function database($database, $query, $parameters){
$result;
$mysqli = new mysqli("****", "****", "****", $database);
if(mysqli_connect_errno()){
return "Connect failed: %s
" . mysqli_connect_error();
}
if(!$stmt = $mysqli->prepare($query)){
return $mysqli->error;
}
if(!$stmt->bind_param($this->convertArrayReferences($parameters))){
return $mysqli->error;
}
if(!$stmt->bind_result($result)){
return $mysqli->error;
}
if(!$stmt->execute()){
return $mysqli->error;
}
$stmt->close();
return $mysqli->error;
}
}
the bit of code where the function is called:
$execute = $sql->database("survivalTmpReg",
"INSERT INTO USERS (name, surname, email, username, password) VALUES (?, ?, ?, ?, ?)",
array("sssss", $name, $surname, $email, $username, $password));
if($execute){
$message = REGISTER_MESSAGE;
}else{
$message = $execute;
}