Welcome Guest, Not a member yet? Register   Sign In
Help required with update and insert
#21

[eluser]the_unforgiven[/eluser]
Its not missing i had to shorten code down has there's a 3000 char limit on this forum and must have missed that off but it's on my controller in textmate, so its something else
#22

[eluser]the_unforgiven[/eluser]
here's a screen shot of whats happening
#23

[eluser]LuckyFella73[/eluser]
What is your $config['log_threshold'] in config.php ?
If not allready set it to 2 or 3 and check you logfile.

Usually you should get an error message when you code
is buggy not just a white screen.

I would start with basic debugging like taking away all
db stuff and just see if the method is entered where you
think it should and echo something. Like this:
Code:
function update()
{
    $this->load->helper('form');
    $this->load->library('form_validation');
    
    if ( isset($_POST['form']) AND $_POST['form'] == 'edit' )
    {
        echo "form was submitted";
        exit();
    }
    else
    {
$this->id = $this->uri->segment(3)
        echo "Get data from DB now. ID is:".$this->id;
        exit();
    }
If you get a white page here you have a code problem elsewhere.

Then add code more and more till you find the problem.
#24

[eluser]the_unforgiven[/eluser]
Yes thats what i've been doing but will do again to see where it's going wrong as for log

Code:
$config['log_threshold'] = 0;
and i have changed it to 3 now.
#25

[eluser]the_unforgiven[/eluser]
It seems to be something with the first else statement here:

Code:
else
            {
                $this->id = $this->uri->segment(3);
                $data['id'] = $this->id;

                # Get DB data
                $query = $this->page_model->getAllPages($this->id);
I took
all
this
out and the else
statement
echo
"This is the last
else statement!";
echo's out so somethings wrong somewhere
                if ($query === FALSE)
                {
                    echo ("query failed");
                    exit();
                }
                if ($query->num_rows() > 0)
                {
                    foreach ($query->result() as $row)
                    {
                        $data['id'] = $this->id;
                        $data['name'] = $row->name;
                        $data['description'] = $row->description;
                        $data['keywords'] = $row->keywords;
                        $data['content'] = $row->content;
                        $data['status'] = $row->status;
                    }
                }
                else
                {
                    echo "This is the last else statement!";
                    exit();
                }
                // send db data to the form
                $this->load->view('admin/editpage', $data);
            }
#26

[eluser]the_unforgiven[/eluser]
I've tried all sorts but don't know why this is still showing has a blank page, wished it would show me an error!!
#27

[eluser]the_unforgiven[/eluser]
any advise?
#28

[eluser]LuckyFella73[/eluser]
Next office day started now ...

Could you attach you complete controller file in your next post?
I could save it in a clean CI setup, comment out the model calls
and see if I get a white page. I have some work to do myself but
I'll try to help you as soon I have some free minutes.
#29

[eluser]the_unforgiven[/eluser]
<?php

class Admin extends CI_Controller {


function index()
{
// Load Libary & Helper Files
$this->load->database('ci');
$this->load->library(array('encrypt', 'form_validation', 'pagination', 'session'));
$this->load->helper(array('form', 'url'));
$this->load->view('admin/dashboard');
$id = $this->session->userdata('session_id');
}



// Success for edited page
function pagesuccess() {
$data['title'] = 'Page Updated';
$this->load->view('admin/pagesuccess', $data);

}
// Pages Function
function pages() {

$data = array();

if($query = $this->page_model->getAllPages())
{
$data['pages'] = $query;
$data['title'] = 'Page Management';
}

$this->load->view('admin/pages', $data);

}
//Update Function
function update() {
$this->load->helper('form');
$this->load->library('form_validation');

$this->id = $this->uri->segment(3);
$data['id'] = $this->id;

if (!empty($_POST['form']) AND $_POST['form'] == 'edit')
{
# Form was send:
$this->id = $this->input->post('id');

$this->load->helper('form');
$this->load->library('form_validation');

# Rules:
$this->form_validation->set_rules('name', 'Page Title', 'trim|required|min_length[2]|max_length[120]');
$this->form_validation->set_rules('description', 'Description', 'trim|required|min_length[3]|max_length[160]');
$this->form_validation->set_rules('keywords', 'Keywords', 'trim|required|min_length[3]|max_length[160]');
$this->form_validation->set_rules('content', 'Content', 'trim|required|min_length[3]|max_length[2000]');



if ($this->form_validation->run() == TRUE)
{

$data['id'] = $this->input->post('id');
$data['name'] = $this->input->post('name');
$data['description'] = $this->input->post('description');
$data['keywords'] = $this->input->post('keywords');
$data['content'] = $this->input->post('content');
$data['status'] = $this->input->post('status');

$this->load->view('admin/editpage', $data);
}
else
{
$data = array(
'name' => $this->input->post('name'),
'description' => $this->input->post('description'),
'keywords' => $this->input->post('keywords'),
'content' => $this->input->post('content'),
'status' => $this->input->post('status')

);

$query = $this->page_model->update_page($data, $this->id);

if ( $query === FALSE)
{
$data['msg'] .= 'failed'; // echo in view file
}
redirect('admin/editpage', 'refresh');
}
}
else
{
$this->id = $this->uri->segment(3);
$data['id'] = $this->id;

//Get DB data
$query = $this->page_model->getAllPages($this->id);
//$query = $this->page_model->update_page($data, $this->id);

if ($query === FALSE)
{
echo "query failed";
//exit();
}
if ($query->num_rows() > 0)
{
foreach ($query->result() as $row)
{
$data['id'] = $this->id;
$data['name'] = $row->name;
$data['description'] = $row->description;
$data['keywords'] = $row->keywords;
$data['content'] = $row->content;
$data['status'] = $row->status;
}
}
else
{
echo "This is the last else statement!";
//exit();
}
// send db data to the form
$this->load->view('admin/editpage', $data);
}
}


// Delete Page
function delete() {
$this->page_model->delete_page();
$data['title'] = 'Page Deleted';
$this->load->view('admin/deletesuccess', $data);
}

}
?>
#30

[eluser]the_unforgiven[/eluser]
I have posted full controller above, also tried taking out bits of the controller including method calling and still a blank white page




Theme © iAndrew 2016 - Forum software by © MyBB