codeigniter flashdata success message returned failed
I updated some data and it returns to failed when it successfully update or not.
Here is my controller code:
$data['edit_cli'] = $this->clients_model->edit_cli();
if(!empty($data['edit_cli'])){
$_SESSION['cli_updated'] = '<div class="alert alert-success cli_updated">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
Client Updated Successfully
</div>';
$this->session->mark_as_flash('cli_updated');
}
else{
$_SESSION['cli_updated'] = '<div class="alert alert-danger cli_updated">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
Client Updated Failed
</div>';
$this->session->mark_as_flash('cli_updated');
}
what I want:
If data is updated successfully it returns only Client Updated Successfully
And If it can not be updated successfully it returns Client Updated Failed
.
Is there a bug in my controller code, possibly my if
conditions?
Here is my model
code:
function edit_cli(){
date_default_timezone_set('Asia/Dhaka');
$date = date('Y-m-d',time());
$cli_id = $this->input->post('client_id');
$data = array(
'product_id' => $this->input->post('product_id'),
'clientName' => $this->input->post('clientName'),
'companyName' => $this->input->post('companyName'),
'client_info_doc' => $date,
'client_info_created_by' => $this->session->userdata('user_id')
);
$this->db->where('client_id', $cli_id);
$this->db->update('tbl_client_info', $data);
}
php mysql codeigniter-3
add a comment |
I updated some data and it returns to failed when it successfully update or not.
Here is my controller code:
$data['edit_cli'] = $this->clients_model->edit_cli();
if(!empty($data['edit_cli'])){
$_SESSION['cli_updated'] = '<div class="alert alert-success cli_updated">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
Client Updated Successfully
</div>';
$this->session->mark_as_flash('cli_updated');
}
else{
$_SESSION['cli_updated'] = '<div class="alert alert-danger cli_updated">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
Client Updated Failed
</div>';
$this->session->mark_as_flash('cli_updated');
}
what I want:
If data is updated successfully it returns only Client Updated Successfully
And If it can not be updated successfully it returns Client Updated Failed
.
Is there a bug in my controller code, possibly my if
conditions?
Here is my model
code:
function edit_cli(){
date_default_timezone_set('Asia/Dhaka');
$date = date('Y-m-d',time());
$cli_id = $this->input->post('client_id');
$data = array(
'product_id' => $this->input->post('product_id'),
'clientName' => $this->input->post('clientName'),
'companyName' => $this->input->post('companyName'),
'client_info_doc' => $date,
'client_info_created_by' => $this->session->userdata('user_id')
);
$this->db->where('client_id', $cli_id);
$this->db->update('tbl_client_info', $data);
}
php mysql codeigniter-3
I see nothing wrong with theif
condition. What exactly does the model return?
– DFriend
Nov 12 '18 at 4:11
1
it couldn't returnif
statement. after updated it returns onlyelse
statement.
– Sabbir
Nov 12 '18 at 4:18
Please edit the question and include the model code.
– DFriend
Nov 12 '18 at 4:36
1
@DFriend , Please check my question. I included model code.
– Sabbir
Nov 12 '18 at 5:11
add a comment |
I updated some data and it returns to failed when it successfully update or not.
Here is my controller code:
$data['edit_cli'] = $this->clients_model->edit_cli();
if(!empty($data['edit_cli'])){
$_SESSION['cli_updated'] = '<div class="alert alert-success cli_updated">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
Client Updated Successfully
</div>';
$this->session->mark_as_flash('cli_updated');
}
else{
$_SESSION['cli_updated'] = '<div class="alert alert-danger cli_updated">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
Client Updated Failed
</div>';
$this->session->mark_as_flash('cli_updated');
}
what I want:
If data is updated successfully it returns only Client Updated Successfully
And If it can not be updated successfully it returns Client Updated Failed
.
Is there a bug in my controller code, possibly my if
conditions?
Here is my model
code:
function edit_cli(){
date_default_timezone_set('Asia/Dhaka');
$date = date('Y-m-d',time());
$cli_id = $this->input->post('client_id');
$data = array(
'product_id' => $this->input->post('product_id'),
'clientName' => $this->input->post('clientName'),
'companyName' => $this->input->post('companyName'),
'client_info_doc' => $date,
'client_info_created_by' => $this->session->userdata('user_id')
);
$this->db->where('client_id', $cli_id);
$this->db->update('tbl_client_info', $data);
}
php mysql codeigniter-3
I updated some data and it returns to failed when it successfully update or not.
Here is my controller code:
$data['edit_cli'] = $this->clients_model->edit_cli();
if(!empty($data['edit_cli'])){
$_SESSION['cli_updated'] = '<div class="alert alert-success cli_updated">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
Client Updated Successfully
</div>';
$this->session->mark_as_flash('cli_updated');
}
else{
$_SESSION['cli_updated'] = '<div class="alert alert-danger cli_updated">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
Client Updated Failed
</div>';
$this->session->mark_as_flash('cli_updated');
}
what I want:
If data is updated successfully it returns only Client Updated Successfully
And If it can not be updated successfully it returns Client Updated Failed
.
Is there a bug in my controller code, possibly my if
conditions?
Here is my model
code:
function edit_cli(){
date_default_timezone_set('Asia/Dhaka');
$date = date('Y-m-d',time());
$cli_id = $this->input->post('client_id');
$data = array(
'product_id' => $this->input->post('product_id'),
'clientName' => $this->input->post('clientName'),
'companyName' => $this->input->post('companyName'),
'client_info_doc' => $date,
'client_info_created_by' => $this->session->userdata('user_id')
);
$this->db->where('client_id', $cli_id);
$this->db->update('tbl_client_info', $data);
}
php mysql codeigniter-3
php mysql codeigniter-3
edited Nov 12 '18 at 5:10
asked Nov 12 '18 at 2:13
Sabbir
13913
13913
I see nothing wrong with theif
condition. What exactly does the model return?
– DFriend
Nov 12 '18 at 4:11
1
it couldn't returnif
statement. after updated it returns onlyelse
statement.
– Sabbir
Nov 12 '18 at 4:18
Please edit the question and include the model code.
– DFriend
Nov 12 '18 at 4:36
1
@DFriend , Please check my question. I included model code.
– Sabbir
Nov 12 '18 at 5:11
add a comment |
I see nothing wrong with theif
condition. What exactly does the model return?
– DFriend
Nov 12 '18 at 4:11
1
it couldn't returnif
statement. after updated it returns onlyelse
statement.
– Sabbir
Nov 12 '18 at 4:18
Please edit the question and include the model code.
– DFriend
Nov 12 '18 at 4:36
1
@DFriend , Please check my question. I included model code.
– Sabbir
Nov 12 '18 at 5:11
I see nothing wrong with the
if
condition. What exactly does the model return?– DFriend
Nov 12 '18 at 4:11
I see nothing wrong with the
if
condition. What exactly does the model return?– DFriend
Nov 12 '18 at 4:11
1
1
it couldn't return
if
statement. after updated it returns only else
statement.– Sabbir
Nov 12 '18 at 4:18
it couldn't return
if
statement. after updated it returns only else
statement.– Sabbir
Nov 12 '18 at 4:18
Please edit the question and include the model code.
– DFriend
Nov 12 '18 at 4:36
Please edit the question and include the model code.
– DFriend
Nov 12 '18 at 4:36
1
1
@DFriend , Please check my question. I included model code.
– Sabbir
Nov 12 '18 at 5:11
@DFriend , Please check my question. I included model code.
– Sabbir
Nov 12 '18 at 5:11
add a comment |
2 Answers
2
active
oldest
votes
You are not returning anything from model ! Please return the result from your model. So, please replace this line at the end line in your model code then see what happens .
.
$result = $this->db->update('tbl_client_info', $data);
return $result;
For that change this line in your contoller's if condition
if($data['edit_cli']){
//your code here
}else{
//your code here
}
because you r returning 0 or 1 always .That's why result is not empty !
1
nowif
condition returns successfully. butelse
couldn't if my field is empty.
– Sabbir
Nov 12 '18 at 5:37
Hey bro was it ok now ?
– M. Alim
Nov 12 '18 at 6:26
no brother. If I couldn't updated data it will be shown Updated Failed. But Now it returns only Successfully msg.
– Sabbir
Nov 12 '18 at 6:29
Have change your controller as suggested ?
– M. Alim
Nov 12 '18 at 6:36
yes I changed it.
– Sabbir
Nov 12 '18 at 6:41
|
show 2 more comments
You might consider changing the if
logic a little. But as M. Alim pointed out, you must return something from the model. Change the last line of the model to
return $this->db->update('tbl_client_info', $data);
The method $this->db->update()
will return TRUE or FALSE.
The code
if(!empty($data['edit_cli'])){
// successful message
} else {
// failed message
}
should be changed to
if($data['edit_cli'] === TRUE){
// successful message
} else {
// failed message
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53255206%2fcodeigniter-flashdata-success-message-returned-failed%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You are not returning anything from model ! Please return the result from your model. So, please replace this line at the end line in your model code then see what happens .
.
$result = $this->db->update('tbl_client_info', $data);
return $result;
For that change this line in your contoller's if condition
if($data['edit_cli']){
//your code here
}else{
//your code here
}
because you r returning 0 or 1 always .That's why result is not empty !
1
nowif
condition returns successfully. butelse
couldn't if my field is empty.
– Sabbir
Nov 12 '18 at 5:37
Hey bro was it ok now ?
– M. Alim
Nov 12 '18 at 6:26
no brother. If I couldn't updated data it will be shown Updated Failed. But Now it returns only Successfully msg.
– Sabbir
Nov 12 '18 at 6:29
Have change your controller as suggested ?
– M. Alim
Nov 12 '18 at 6:36
yes I changed it.
– Sabbir
Nov 12 '18 at 6:41
|
show 2 more comments
You are not returning anything from model ! Please return the result from your model. So, please replace this line at the end line in your model code then see what happens .
.
$result = $this->db->update('tbl_client_info', $data);
return $result;
For that change this line in your contoller's if condition
if($data['edit_cli']){
//your code here
}else{
//your code here
}
because you r returning 0 or 1 always .That's why result is not empty !
1
nowif
condition returns successfully. butelse
couldn't if my field is empty.
– Sabbir
Nov 12 '18 at 5:37
Hey bro was it ok now ?
– M. Alim
Nov 12 '18 at 6:26
no brother. If I couldn't updated data it will be shown Updated Failed. But Now it returns only Successfully msg.
– Sabbir
Nov 12 '18 at 6:29
Have change your controller as suggested ?
– M. Alim
Nov 12 '18 at 6:36
yes I changed it.
– Sabbir
Nov 12 '18 at 6:41
|
show 2 more comments
You are not returning anything from model ! Please return the result from your model. So, please replace this line at the end line in your model code then see what happens .
.
$result = $this->db->update('tbl_client_info', $data);
return $result;
For that change this line in your contoller's if condition
if($data['edit_cli']){
//your code here
}else{
//your code here
}
because you r returning 0 or 1 always .That's why result is not empty !
You are not returning anything from model ! Please return the result from your model. So, please replace this line at the end line in your model code then see what happens .
.
$result = $this->db->update('tbl_client_info', $data);
return $result;
For that change this line in your contoller's if condition
if($data['edit_cli']){
//your code here
}else{
//your code here
}
because you r returning 0 or 1 always .That's why result is not empty !
edited Nov 12 '18 at 6:25
answered Nov 12 '18 at 5:18
M. Alim
12313
12313
1
nowif
condition returns successfully. butelse
couldn't if my field is empty.
– Sabbir
Nov 12 '18 at 5:37
Hey bro was it ok now ?
– M. Alim
Nov 12 '18 at 6:26
no brother. If I couldn't updated data it will be shown Updated Failed. But Now it returns only Successfully msg.
– Sabbir
Nov 12 '18 at 6:29
Have change your controller as suggested ?
– M. Alim
Nov 12 '18 at 6:36
yes I changed it.
– Sabbir
Nov 12 '18 at 6:41
|
show 2 more comments
1
nowif
condition returns successfully. butelse
couldn't if my field is empty.
– Sabbir
Nov 12 '18 at 5:37
Hey bro was it ok now ?
– M. Alim
Nov 12 '18 at 6:26
no brother. If I couldn't updated data it will be shown Updated Failed. But Now it returns only Successfully msg.
– Sabbir
Nov 12 '18 at 6:29
Have change your controller as suggested ?
– M. Alim
Nov 12 '18 at 6:36
yes I changed it.
– Sabbir
Nov 12 '18 at 6:41
1
1
now
if
condition returns successfully. but else
couldn't if my field is empty.– Sabbir
Nov 12 '18 at 5:37
now
if
condition returns successfully. but else
couldn't if my field is empty.– Sabbir
Nov 12 '18 at 5:37
Hey bro was it ok now ?
– M. Alim
Nov 12 '18 at 6:26
Hey bro was it ok now ?
– M. Alim
Nov 12 '18 at 6:26
no brother. If I couldn't updated data it will be shown Updated Failed. But Now it returns only Successfully msg.
– Sabbir
Nov 12 '18 at 6:29
no brother. If I couldn't updated data it will be shown Updated Failed. But Now it returns only Successfully msg.
– Sabbir
Nov 12 '18 at 6:29
Have change your controller as suggested ?
– M. Alim
Nov 12 '18 at 6:36
Have change your controller as suggested ?
– M. Alim
Nov 12 '18 at 6:36
yes I changed it.
– Sabbir
Nov 12 '18 at 6:41
yes I changed it.
– Sabbir
Nov 12 '18 at 6:41
|
show 2 more comments
You might consider changing the if
logic a little. But as M. Alim pointed out, you must return something from the model. Change the last line of the model to
return $this->db->update('tbl_client_info', $data);
The method $this->db->update()
will return TRUE or FALSE.
The code
if(!empty($data['edit_cli'])){
// successful message
} else {
// failed message
}
should be changed to
if($data['edit_cli'] === TRUE){
// successful message
} else {
// failed message
}
add a comment |
You might consider changing the if
logic a little. But as M. Alim pointed out, you must return something from the model. Change the last line of the model to
return $this->db->update('tbl_client_info', $data);
The method $this->db->update()
will return TRUE or FALSE.
The code
if(!empty($data['edit_cli'])){
// successful message
} else {
// failed message
}
should be changed to
if($data['edit_cli'] === TRUE){
// successful message
} else {
// failed message
}
add a comment |
You might consider changing the if
logic a little. But as M. Alim pointed out, you must return something from the model. Change the last line of the model to
return $this->db->update('tbl_client_info', $data);
The method $this->db->update()
will return TRUE or FALSE.
The code
if(!empty($data['edit_cli'])){
// successful message
} else {
// failed message
}
should be changed to
if($data['edit_cli'] === TRUE){
// successful message
} else {
// failed message
}
You might consider changing the if
logic a little. But as M. Alim pointed out, you must return something from the model. Change the last line of the model to
return $this->db->update('tbl_client_info', $data);
The method $this->db->update()
will return TRUE or FALSE.
The code
if(!empty($data['edit_cli'])){
// successful message
} else {
// failed message
}
should be changed to
if($data['edit_cli'] === TRUE){
// successful message
} else {
// failed message
}
answered Nov 12 '18 at 5:47
DFriend
6,9041520
6,9041520
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53255206%2fcodeigniter-flashdata-success-message-returned-failed%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I see nothing wrong with the
if
condition. What exactly does the model return?– DFriend
Nov 12 '18 at 4:11
1
it couldn't return
if
statement. after updated it returns onlyelse
statement.– Sabbir
Nov 12 '18 at 4:18
Please edit the question and include the model code.
– DFriend
Nov 12 '18 at 4:36
1
@DFriend , Please check my question. I included model code.
– Sabbir
Nov 12 '18 at 5:11