Jump to content

Updating in Codeigniter


booxvid

Recommended Posts

I don't where this error come from \:

The error was:

Error Number: 1146

 

Table 'test.idblog_user' doesn't exist

 

SELECT * FROM (`idblog_user`) WHERE `email` = 'asdjasd@yahoo.com' LIMIT 1

 

Filename: C:\xampp\htdocs\CodeIgniter_2.1.2\system\database\DB_driver.php

 

Line Number: 330

my function update in my model

[code=php:0]	public function update_posts($data,$id){
		$this->db->where('idblog_user', $id)
		       ->update('blog_user',$data);
		return;
	}

[/code]

 

my two functions in my controller

[code=php:0]public function updateform(){
				$data = array();
				$data['posts']=$this->blog_model->getthis_records();
				$this->load->view('view_update',$data);	

	}

	public function updatethis(){
					$this->form_validation->set_rules('firstname','First Name','required|alpha_numeric');
			       $this->form_validation->set_rules('lastname','Last Name','required|alpha_numeric');
			       $this->form_validation->set_rules('gender','Gender','required');
			       $this->form_validation->set_rules('month','Month','required');
			       $this->form_validation->set_rules('month','Day','required');
			       $this->form_validation->set_rules('year','Year','required');
			       $this->form_validation->set_rules('email','Email Address','required|valid_email|is_unique[idblog_user.email]');
			       $this->form_validation->set_rules('username','Username','required|min_length[5]|max_length[12]|is_unique[idblog_user.username]|alpha_dash');
			       $this->form_validation->set_rules('password','Password','required|min_length[6]|max_length[12]');		
			       
			       $this->form_validation->set_error_delimiters('<br /><span class="error"> ','</span>');
			       if($this->form_validation->run()){
			       		  
				      	$fname =$this->input->post('firstname');
						$lname = $this->input->post('lastname');
						$gender = $this->input->post('gender');
						$month = $this->input->post('month');
						$day = $this->input->post('day');
						$year = $this->input->post('year');
						$date = sprintf('%s-%s-%s',$year,$month,$day);
						$eadd = $this->input->post('email');
						$username = $this->input->post('username');
						$password = $this->input->post('password');			
						$data = array('firstname'=>$fname,'lastname'=>$lname,'gender'=>$gender,
								'birthday'=>$date,'email'=>$eadd,'username'=>$username,'password'=>$password);
						$id=$this->uri->segment(3);
						$printquery = $this->blog_model->update_posts($data,$id);
						echo $printquery;
						if($this->blog_model->update_posts($data,$id)){
							redirect();
						}
						else{
						//	$this->messages->error('There was an error updating this product\'s attributes...');
							echo "UN";
						}
			       }
						  
			  

	}

[/code]

 

and in my view:

[code=php:0]	<div>
			<?php echo heading('Current Data:',3);?>
			<?php foreach ($posts as $p):?>
			<?php echo form_label('First Name:','firstname')." ". $p['firstname'];
					echo br(2);?>
			<?php echo form_label('Last Name:','lastname')." ". $p['lastname'];
					echo br(2);?>
			<?php echo form_label('Birthday:','birthday')." ". $p['birthday'];
					echo br(2);?>
			<?php echo form_label('Email Address:','email')." ". $p['email'];
					echo br(2);?>
			<?php echo form_label('Username:','username')." ". $p['username'];
					echo br(2);?>
			<?php endforeach;
				echo nbs(4);?>

		</div>
                  <div>
                   
		<div class="form">
<?php foreach ($posts as $p):?>

			<?php 
				$attributes = array('class'=>'well form-inline','id'=>'thisForm');

				echo form_open('blog/updatethis/'.$p['idblog_user'].'',$attributes)?>
				<?php endforeach;?>
				<table cellspacing="2" cellpadding="10" border=0>
				<tr>
					<td><?php echo heading('REGISTRATION FORM',3);?></td>
				</tr>
				<tr>
					<td><?php echo form_label('First Name:','firstname')?></td>
					<td><?php 
							$data_input_fname = array('class'=>'input-large',
												'name'=>'firstname',
												'id'=>'firstname',
												'maxlength'=>'100');		

							echo form_input($data_input_fname);
					?>
					</td>
				</tr>
				<tr>
					<td><?php echo form_label('Last Name:','lastname')?></td>
					<td><?php 
							$data_input_lname = array('class'=>'input-large',
												'name'=>'lastname',
												'id'=>'lastname',
												'maxlength'=>'100');

							echo form_input($data_input_lname);
					?></td>
				</tr>
				<tr>
					<td><?php echo form_label('Gender:','gender')?></td>
					<td><?php

							$gender_f = array('name'=>'gender',
											'type'=>'radio');
							$gender_m = array('name'=>'gender',
											'type'=>'radio'
											,'value'=>'Male'); 
							echo form_radio($gender_f).' Female';
							echo nbs(3);
							  echo form_radio($gender_m).' Male';
					?></td>
				</tr>
				<tr>
					<td><?php echo form_label('Birthday:','birthday')?></td>
					<td><?php 
							$options = array(''=>'Month',
											'01'=>'January',
											'02'=>'February',
											'03'=>'March',
											'04'=>'April',
											'05'=>'May',
											'06'=>'June',
											'07'=>'July',
											'08'=>'August',
											'09'=>'Septembr',
											'10'=>'October',
											'11'=>'November',
											'12'=>'December');

							echo form_dropdown('month',$options,'');

							$options2 = array(''=>'Day',
											'01'=>'1',
											'02'=>'2',
											'03'=>'3',
											'04'=>'4',
											'05'=>'5',
											'06'=>'6',
											'07'=>'7',
											'08'=>'8',
											'09'=>'9',
											'10'=>'10',
											'11'=>'11',
											'12'=>'12',
											'13'=>'13',
											'14'=>'14',
											'15'=>'15',
											'16'=>'16',
											'17'=>'17',
											'18'=>'18',
											'19'=>'12',
											'20'=>'20',
											'21'=>'21',
											'22'=>'22',
											'23'=>'23',
											'24'=>'24',
											'25'=>'25',
											'26'=>'26',
											'27'=>'27',
											'28'=>'28',
											'29'=>'29',
											'30'=>'30',
											'31'=>'31');	

							echo form_dropdown('day',$options2,'');

							$year = array();
							for($i=1800;$i<=2012;$i++){
								$year[$i]= $i;
							}

							$year_my = array_combine($year,$year);

							echo form_dropdown('year', $year_my);
					?></td>
				</tr>
				<tr>
					<td><?php echo form_label('Email:','email address')?></td>
					<td><?php 	$data_inpute = array('class'=>'input-large',
												'name'=>'email',
												'id'=>'email',
												'maxlength'=>'100');
								echo form_input($data_inpute);

					?></td>
				</tr>
				<tr>
					<td><?php echo form_label('Username:','username')?></td>
					<td><?php 	$data_input = array('class'=>'input-large',
												'name'=>'username',
												'id'=>'username',
												'maxlength'=>'100');
								echo form_input($data_input);

					?></td>
				</tr>
				<tr>
					<td><?php echo form_label('Password:','password')?></td>
					<td><?php 	$data_pass = array('class'=>'input-large',
												'name'=>'password',
												'id'=>'password',
												'maxlength'=>'100',
												'type'=>'password');
								echo form_password($data_pass);
					?></td>
				</tr>
				<tr>
					<td colspan=2>
					<?php	if(validation_errors()):
							echo validation_errors();
						endif;?>
					</td>
				</tr>

				<tr>
					<td colspan="2"><center>
					<?php 
							$submit_data = array('type'=>'submit',
												'class'=>'white button',
												'name'=>'submit_form',
												'value'=>'Submit!');
							echo form_submit($submit_data);

							$reset_data = array('type'=>'reset',
												'class'=>'white button',
												'name'=>'reset_form',
												'value'=>'Reset!');
							echo form_reset($reset_data);?></center>
					</td>
				</tr>
				<?php form_close();?>

			</table>
		</div>
	  </div>

[/code]

 

 

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.