Ir para conteúdo
Fórum Script Brasil
  • 0

(Resolvido) Undefined variable


Temoso

Pergunta

Olá galera, eu estou usando um script embora o script esteja funfado certinho, fica um erro visualmente chato no topo do site... o erro é:

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: table

Filename: controllers/fotos.php

meu arquivo fotos.php ta assim:

<?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 src=\"$url/".$row['IMAGE']."\" 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 */
?>

Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

  • 0

tens duas opcoes axo eu,

1º (não recomendo) desligar os avisos e erros no ficheiro php.ini no teu servidor

2º : axo k deves por no inicio da pagina

$table="";

ou

$table==NULL;

fora dos teus ciclos for, if e assim

ele aki fica definido, mas kuando entrar no teu script toma outro valor por isso isto deve resolver o teu problema.

depois diz se funcionou

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...