Welcome Guest, Not a member yet? Register   Sign In
[UNFIXED] Help "Error 101 (net::ERR_CONNECTION_RESET)"
#1

[eluser]EdLongman[/eluser]
I get this error when ever I load my url an I don't have a clue what is wrong with it.
I have isolated the lines in which there is a problem and I think it this function in my model
Code:
class Book_model extends Model{
    function getAll($table) {
        $rows = $this->db->get($table);
        if($rows->num_rows()>0){
            foreach($rows->result() as $row){
                $data[]=$row;
            }
        return $data;
        }
    }
When i comment out the function and in particular this line,
Code:
$rows = $this->db->get($table);
I get other errors but the page loads.
Although when I comment out this line it works I think that the source of the problem is actually this line,
Code:
if($rows->num_rows()>0){
and then its the num_rows function.
#2

[eluser]Abdul Malik Ikhsan[/eluser]
if you will temp your result to array, you can use result_array() function :
Code:
<?php
  $rows = $this->db->get($table)->result_array();
   echo "<pre>";
   print_r($rows);
#3

[eluser]EdLongman[/eluser]
changed it to
Code:
function getAll($table) {
    $rows = $this->db->get($table)->result_array();
    if(count($rows)>0){
        foreach($rows as $row){
            $data[]=$row;
        }
        return $data;
    }
}
but it still refuses to work.
#4

[eluser]Abdul Malik Ikhsan[/eluser]
Code:
$rows = $this->db->get($table)->result_array();
//-> the $rows is an array like $data
so you can use
Code:
if (count($rows)>0)
    return $rows;
else
    return 'no data in this table ';

if it's still fault, maybe you try (query ) :
Code:
$rows = $this->db->query("select * from `$table`")->result_array();
if (count($rows)>0)
    return $rows;
else
    return 'no data in this table ';
#5

[eluser]EdLongman[/eluser]
My function now reads,
Code:
function getAll($table) {
    $rows = $this->db->get($table)->result_array();
    if(count($rows)>0){
        return $data;
    }
    else{
        return false;
    }
}
And yet I still get the error and it STILL doesn't work?
#6

[eluser]Abdul Malik Ikhsan[/eluser]
hm..., what database you used ? maybe it's in the corrupt database
#7

[eluser]EdLongman[/eluser]
I use mysql
and it is definitely not a corrupt DB because I have tested it on PHPMYADMIN and it works fine and I have another use for the same table but that doesn't use codeigniter.
#8

[eluser]Abdul Malik Ikhsan[/eluser]
have you try :
Code:
$rows = $this->db->query("select * from `$table`")->result_array();
?
#9

[eluser]EdLongman[/eluser]
I have now and that doesn't seem to work either
#10

[eluser]Abdul Malik Ikhsan[/eluser]
hm..., how about database configuration ?




Theme © iAndrew 2016 - Forum software by © MyBB