Welcome Guest, Not a member yet? Register   Sign In
Undefined variable: table
#1

[eluser]Unknown[/eluser]
Hello,

I'm getting the error:

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: table

Filename: controllers/fotos.php



because this error is occurring?

my file fotos.php

Code:
<?php

class Fotos extends Controller {
    
    function _imagens($dir){
    if(!$dir){$dir = '.';}
    foreach(glob("$dir/*") as $item){$sort[]= end(explode('/',$item));}
    $killit = array('index.html', 'index.php', 'thumbs.db', 'styles.css');
    $killcounter = 0;
    foreach($sort as $sorteditem){
        foreach($killit as $killcheck){
            if(strtolower($sorteditem) == strtolower($killcheck))
            {unset($sort[$killcounter]);}
        }$killcounter++;}
        if($sort){natsort($sort);}
        foreach($sort as $item){$return[]= $item;}

        if(!$return){return array();}
        return $return;
    }
    
    function galeria($galleryName)
    {
        
        $this->load->helper('url');
        $query = $this->db->query("SELECT IMAGE FROM TB_IMAGES WHERE DESCGALERIA = '$galleryName'");
        $result = $query->result_array();
        if ($query->num_rows() > 0){
            echo 'teste';
            $this->output->cache(999999);
            $table.="</table>\n";
               foreach ($query->result_array() as $row)
                   {
        $url = base_url().$galleryName;
        $table.="<tr>\n<td align=\"center\" cellspacing='4'>";
        $table.="<a href='http://www.mysite.com' target='_blank'><img  alt='www.mysite.com' class='thumbHome' border='4'></a>";
        $table.="<br/>";
        $table.="</td>\n</tr>\n";
               }
        $table.="</table>\n";
            $dados['table'] = $table;
            $dados['pageTitle'] = 'Galeria de Fotos';
            $this->load->view('galleryView',$dados);
        }
        else {
            $allimages = $this->_imagens($galleryName);
            print_r($allimages);
            foreach($allimages as $image){
            $sql = "INSERT INTO TB_IMAGES (DESCGALERIA,IMAGE) VALUES (".$this->db->escape($galleryName).", ".$this->db->escape($image).")";
            $this->db->query($sql);
            }
        }
        
        
    }
}

/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */
?&gt;
#2

[eluser]eric cumbee[/eluser]
i think it is because you are trying to append a string to a variable that you have not declared.




Theme © iAndrew 2016 - Forum software by © MyBB