Jump to content
MP123

Erros Undefined index&Variable

Recommended Posts

MP123

Boas pessoal

Eu sou novo aqui e tambem sou novo em php eu saquei um script (pesquisa) para um site qe estou a fazer e funciona mas dá 3 erros que nao sei resolver :\ pf ajudem-me

<head>
<meta http-equiv="Content-language" content="cs" >
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
<meta name="description" content="" >
<meta name="keywords" content="" >
<title>ACIGaia-Associa&#231;&#227;o Comercial e Industrial de V.N.Gaia</title>
<link rel="stylesheet" type="text/css" href="css.css" >
</head>
<body>



<div id=WholePage>

<div id="Container">

    <div id="Top">
    
        <div id="Header">
        <div id="RightHeader">
        <a href="index.html" id="home">Home</a>
        <a href="contacto.html" id="contacts">Contactos</a>
        </div>
        <span class="name">ACIGAIA</span><br/>
        <span class="adress">Associa&#231;&#227;o Comercial e Industrial de V.N.Gaia</span>

    	</div>
	<div id="Inter">
        </div>
   	 	<div id="Menu">

<a href="historia.html"><span>Apresenta&#231;&#227;o</span></a>

    	</div>
    </div>
    <div id="Left">
    	    <div id="LeftMenu">

              <div class="LeftHeader">Menu</div>	    

		<span>Servi&#231;os</span>
			<ul>
		<li><a href="servicos administrativos.html">Servi&#231;os Administrativos</a></li>
		<li><a href="gabinete de contabilidade.html">Gabinete Contabilidade</a></li>
		<li><a href="gabinete juridico.html">Gabinete Jur&#237;dico</a></li>
		<li><a href="gabinete tecnico.html">Gabinete T&#233;cnico</a></li>
		<li><a href="dinamizacao economico.html">Dinamiza&#231;&#227;o Econ&#243;mica</a></li>
		<li><a href="condicoes de inscricao.html">Condi&#231;&#245;es de inscri&#231;&#227;o</a></li>
		</ul>
		<span>Concelho V.N.Gaia</span>
		<ul>
		<li><a href="Flash%20Things/caracterizacao.swf" target="_blank">Caracteriza&#231;&#227;o</a></li>
		<li><a href="Flash%20Things/perfil_comercial.swf" target="_blank">Perfil Comercial</a></li>
		<li><a href="Flash%20Things/mapa_actividades.swf" target="_blank">Mapa Actividades</a></li>
		<li><a href="Flash%20Things/mapa_sectores.swf" target="_blank">Mapa Sectores</a></li>
		</ul>
		<span>Informa&#231;&#245;es</span>
		<ul>
		<li><a href="obrigacoes fiscais.html">Obriga&#231;&#245;es Fiscais</a></li>	
		<li><a href="financa.html">Finan&#231;as</a></li>
		<li><a href="apoio a criacao de empresas.html">Apoio a cria&#231;&#227;o das empresas</a></li>
		<li><a href="apoio a empresas.html">Apoio &#224;s empresas</a></li>
		<li><a href="criar emprego.html">Criar Emprego</a></li>
		</ul>
		<ul>
		<center><a href="condicoes de inscricao.html"><img src="img/ins4.gif"></a></center>
		</ul>

            </div>
     
      </div>
    <div id="Middle">
        <div id="Page">
            <div id="Content">
			<div class="Part">
	<h2>Procurar Cae</h2>
	<br>

<?php


//get data
$button = $_GET['submit'];
$search = $_GET['search'];


$s = $_GET['s'];
if (!$s)
$s = 0;


$e = 10; // Just change to how many results you want per page


$next = $s + $e;
$prev = $s - $e;




if (strlen($search)<=2)
  echo "<center><br /><br /><br />A procura tem de ter mais de 3 caracteres </center>";
else
{
  echo "<center><br /><table><tr><td></td><td><form action='search.php' method='GET'><input type='text' onclick=value='' size='30' name='search' value='$search'> <input type='submit' name='submit' value='Procurar'></form></td></tr></table></center>";
  
  //connect to database
  mysql_connect("localhost","root","");
  mysql_select_db("search");
   
   //explode out search term
   $search_exploded = explode(" ",$search);
   
   foreach($search_exploded as $search_each)
   {
   
        //construct query
    $x++;
    if ($x==1)
     $construct .= "keywords LIKE '%$search_each%'";
    else
     $construct .= " OR keywords LIKE '%$search_each%'";
   
   }
   
  //echo outconstruct
  $constructx = "SELECT * FROM searchengine WHERE $construct";
  
  $construct = "SELECT * FROM searchengine WHERE $construct LIMIT $s,$e";
  $run = mysql_query($constructx);
  
  $foundnum = mysql_num_rows($run);


  $run_two = mysql_query("$construct");
  
  if ($foundnum==0)
  
   echo "<br /><br /><center>Nao foram encontrados resultados para <b>$search</b></center>";
  else
  {
   echo "<table bgcolor='#0000FF' width='100%' height='1px'><br /></table><table bgcolor='#f0f7f9' width='100%' height='10px'><tr><td><div align='right'><b>$foundnum</b> resultados encontrados <b>$search.</b></div></td></tr></table><p>";
   
   while ($runrows = mysql_fetch_assoc($run_two))
   {
    //get data
   $title = $runrows['title'];
   $desc = $runrows['description'];
   $url = $runrows['url'];
   
   echo "<table width='300px'>
   <h4><a href='http://$url'><b>$title</b></a><br />
   $desc<br>
</table></h4>
   ";
   }
?>

<table width='100%'>
<tr>
<td>
<div align="center">

<?php
if (!$s<=0)
echo "<a href='search.php?search=$search&s=$prev'>Anterior</a>";

$i =1; 
for ($x=0;$x<$foundnum;$x=$x+$e)
{


echo " <a href='search.php?search=$search&s=$x'>$i</a> ";


$i++;


}

if ($s<$foundnum-$e)
  echo "<a href='search.php?search=$search&s=$next'>Proximo</a>";

}
}  


?>
</div>
</td>
</tr>
</table>
		</div>				




			</div>
		</div>
    </div>
</div>

<div id="Footer">
	    <div id="Bottom">
			<span>Site optimizado por Ma Luoen e Tiago Lameir&#227;o. @ 2010 Todos os Direitos Reservados</span>
	    </div>
 </div>
</div>
<div>
<a href="http://validator.w3.org/check?uri=referer">
</div>

          

</body>
</html>

Da-me erro Notice: Undefined index: s in C:\xampp\htdocs\www\search.php on line 88

Notice: Undefined variable: x in C:\xampp\htdocs\www\search.php on line 119

Notice: Undefined variable: construct in C:\xampp\htdocs\www\search.php on line 121

Agredecia a voça ajuda , obrigado

Share this post


Link to post
Share on other sites
brunoais

Eu não me vou dar ao trabalho de perceber como é que esse código funciona. Pergunta a quem o fez. Isso é demasiado grande para perceber o que é que cada uma dessas coisas deveria fazer.


"[Os jovens da actual geração]não lêem porque não envolve um telecomando que dê para mirar e atirar, não falam porque a trapalhice é rainha e o calão é rei" autor: thoga31

Life is a genetically transmitted disease, induced by sex, with death rate of 100%.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.