[eluser]BoyBlue[/eluser]
I've been trying over the last couple days to get the following code to work but with no luck...I've now reached a point where I just need a fresh set of eyes because it's probably me just missing a period or colon or something.
Controller:
Code:
function confirm_email( $password )
{
if ( $password )
{
$password = $this->uri->segment(3, 0);
$temp_password = $this->uri->segment(4, 0);
$table_name = $this->uri->segment(5, 0);
$email = $this->uri->segment(6, 0);
//Replace Temp Email and Temp_password with 0 and put Password into cell
$new_member_data = array(
/*Place Email Into Email cell*/
'email' => $email,
/*Place Password Into Password cell*/
'password' => $password,
/*Turn temp_email to 0*/
'temp_email' => 0,
/*Turn confirm_password to 0*/
'confirm_password' => 0,
/*Turn temp_password to 0*/
'temp_password' => 0
);
//Update the Database by placing password into position and changing Temp Password and Confirm Password
$this->load->model('model_members');
$this->model_members->update_member($new_member_data);
//Create Member Table with table_name stored in Member table on specific members row
$this->model_members->create_member_table($table_name);
//Get the Game data from Game Table
/*$game_data['new_table_game_data'] =*/
$this->model_members->get_game_data($table_name);
/********Now Load the Page***************/
$this->create_member_success_page();
}
}
Model:
Code:
function update_member($new_member_data)
{
//Test to see if there is a match with passwords
$this->db->select('confirm_password');//Table item(s). If all then remove this line
$this->db->where('temp_password', $this->uri->segment(4));
$query = $this->db->get('members');//name of table in database
//If password match then update the DB
if ($query->num_rows > 0)
{
//Update in Database
THIS SEEMS TO BE LINE WHERE THE DATA IS BEING PULLED FROM TO CREATE ERROR
$this->db->select( 'temp_email, temp_password, confirm_password, password' );//Table item(s). If all then remove this line
$this->db->where('temp_password', $this->uri->segment(4));//This is the element that loads individual rows to be displayed in the the view file
$this->db->update('members', $new_member_data);//users is name of table in database
}
}
function create_member_table($table_name)
{
//Use CI's Database Forge to create new table
$this->load->dbforge();
// Set up Data for inserting into new table
// gives PRIMARY KEY to `whatever_id` (`whatever_id`)
$this->dbforge->add_key('member_rating_id', TRUE);
$fields = array
(
'member_rating_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'auto_increment' => TRUE
),
'game_id' => array(
'type' => 'INT',
'constraint' => '10',
),
);
//Uses the Newly Generated Table Name to create new Table
//first load the fields
$this->dbforge->add_field($fields);
//Then create the table and use the Unique Member Table ID variable as the name
// 2nd variable 'TRUE' gives CREATE TABLE IF NOT EXISTS table_name
$this->dbforge->create_table( $table_name, TRUE);
}
function get_game_data($table_name)
{
$this->db->select('game_id, base_number');//Table item(s). If all then remove this line
THIS IS LINE 153
$game_data = $this->db->get('games');//name of table in database
if ($game_data->num_rows > 0)
{
$this->db->select('game_id, base_number');//Table item(s). If all then remove this line
$this->db->insert($table_name, $game_data);//name of table in database
}
}
Error Message:
Quote:A Database Error Occurred
Error Number: 1054
Unknown column 'temp_email' in 'field list'
SELECT `temp_email`, `temp_password`, `confirm_password`, `password`, `game_id`, `base_number` FROM (`games`)
Filename: /Applications/MAMP/htdocs/beta_new/models/model_members.php
Line Number: 153