- This topic is empty.
Viewing 1 post (of 1 total)
-
AuthorPosts
-
September 3, 2010 at 2:33 pm #30141thisishardMember
Hello, once again i am stuck, once again the problem i am stuck on seems to not be documented on at all any where.
So, i have some code in a class that creates an object of another class and passes some data to this class. The newly created class then runs a stored procedure to a database. The example i am about to give is for inserting some user deatails into the database to create a new user.
public function addUserDetails()
{
$userFirstName = $this->_filtered;
$userLastName = $this->_filtered;
$userMail = $this->_filtered;
$userPassword = $this->_filtered;
$query = "INSERT INTO userDetails (userFirstName, userLastName, userMail, userPassword) VALUES (?, ?, ?, ?)";
$tempVal = $this->_DBConnection->runQuery($query, array(&$userFirstName, &$userLastName, &$userMail, &$userPassword), false);
if($this->_DBConnection->getLastID() == false) {
mail("[email protected]", "Major Error In Creating User", "Please Check Tables For Creating A User. Error in 'register_CreateUser.php' on 'line 79'. Paramaters(UserName = $userFirstName $userLastName, UserMail = $userMail)", "From: [email protected]");
return false;
}
else $this->_userID = $this->_DBConnection->getLastID();
$query2 = "INSERT INTO userActive (userID, userLastSeen, userHash) VALUES (?, ?, ?)";
$userLastSeen = date("M jS Y");
$this->_userHash = md5(uniqid(rand(), true));
$tempVal2 = $this->_DBConnection->runQuery($query2, array(&$this->_userID, &$userLastSeen, &$this->_userHash), false);
if($this->_DBConnection->getLastID() == false || $this->_DBConnection->getLastID() != $this->_userID) {
mail("[email protected]", "Major Error In Creating User", "Please Check Tables For Creating A User. Error in 'register_CreateUser.php' on 'line 88'. Paramaters(UserName = $userFirstName $userLastName, UserMail = $userMail)", "From: [email protected]");
return false;
}
$this->_DBConnection->close();
return true;
}
This is the function that it is calling.
public function runQuery($query, $functionArray = array(), $needResults = true)
{
$stmtParam = "";
$parameters = array();
$results = array();
foreach ($functionArray as $v) {
$stmtParam .= "s";
}
array_unshift($functionArray, $stmtParam);
$stmt = $this->_dbConnection->prepare($query);
call_user_func_array(array($stmt, 'bind_param'), $functionArray);
$stmt->execute();
if($needResults) {
$meta = $stmt->result_metadata();
while ( $field = $meta->fetch_field() ) {
$parameters[] = &$row[$field->name];
}
call_user_func_array(array($stmt, 'bind_result'), $parameters);
while ( $stmt->fetch() ) {
$x = array();
foreach( $row as $key => $val ) {
$x[$key] = $val;
}
$results[] = $x;
}
return $results;
} else return true;
}
So what happens at the moment is that basically nothing, nothing is created in the database. I do however get the first error email of the two.
So i really do not now what is going on. Sorry that this is a long piece of code, i have tried to solve it myself but it has beaten me.
Many Thanks
Chris -
AuthorPosts
Viewing 1 post (of 1 total)
- The forum ‘Back End’ is closed to new topics and replies.