Jump to content


Photo

Undefined Variable


  • Faça o login para participar
1 reply to this topic

#1 Temoso

Temoso

    Turista

  • Usuários
  • 50 posts
  • Sexo:Não informado

Posted 26/03/2010, 14:37

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 */
?>


#2 MBA

MBA

    24 Horas

  • Usuários
  • 412 posts
  • Sexo:Masculino
  • Localidade:Belo Horizonte
  • Interesses:Desenvolvimento WEB

Posted 26/03/2010, 14:50

Boa tarde amigo.
Tudo bom?

Tente iniciar a variável table em algum ponto.
$table = "";

Acho que vai dar certo...
O notice é porque você está usando uma variável que não foi iniciada...

ABraços
Mateus Antunes
MBASistemas




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq