2013-04-03 153 views
0

我认为我有一个标记错误,因为当我将代码分组为“Coda 2”时,它可以工作,但是当我将<html><body>分组时,它会产生错误。我把代码放在你的帮助下找到错误。查找标记错误(分组标记)

当我尝试运行它,它看来,' }else {

echo "<p id='result_fail'>No puede exceder la cantidad especificada de caracteres.</p>";' 

<html> 

    <body> 
<?php 

     include('conexion.php'); 
       //CONDICION PARA LOS ERRORES 
     if(isset($_POST['boton'])){ 
      }else if($_POST['date'] == ''){ 
       $error2 = '<span class="error">Ingrese la fecha</span>'; 
      }else if($_POST['subtitle'] == ''){ 
       $error3 = '<span class="error">Ingrese un subtitle</span>'; 
      }else if($_POST['image'] == ''){ 
       $error4 = '<span class="error">Ingrese la imagen</span>'; 
      }else if ($_POST['text'] == ''){ 
       $error5 = '<span class="error">Ingrese el texto</span>'; 
      }else{ 
       //DECLARAMOS VARIABLES 
       $titulo = $_POST['title']; 
       $fecha = $_POST['date']; 
       $subtitulo = $_POST['subtitle']; //subtitle 
       $imagen = $_POST['image']; //imagen 
       $texto = $_POST['text']; 
       $tiponot = $_POST['type']; 

       //CHEQUEAMOS QUE LOS CONTENIDOS SEAN APROPIADOS 
        if ((strlen($subtitle) <= 75) && (strlen($subtitulo) <= 75) && (strlen($texto) <= 5000)) { 

         $titulo = trim($titulo);//ELIMINA ESPACIOS EN BLANCO 

         $temptitle = trim($titulo);//ELIMINA ESPACIOS EN BLANCO 

         $temptitle = strtolower($temptitle);//CONVIERTE TODO A MINUSCULA 

         //REEMPLAZA LOS CARACTERES CON SIGNOS, TILDES O COMAS, ETC POR CARACTERES LIMPIOS Y LOS ESPACIOS POR RAYAS PARA QUE SEA MEJOR ALMACENADO 
         $b = array("á","é","í","ó","ú","ä","ë","ï","ö","ü","à","è","ì","ò","ù","ñ"," ",",",".",";",":","¡","!","¿","?","/","*","+","´","{","}","¨","â","ê","î","ô","û", "^","#","|","°","=","[","]","&lt;","&gt;","`","(",")","&amp;","%","$","¬", "@","Á","É","Í","Ó","Ú","Ä","Ë","Ï","Ö","Ü","Â","Ê","Î","Ô","Û","~","À", "È","Ì","Ò","Ù","_","\\","\"","\""); 

         $c = array("a","e","i","o","u","a","e","i","o","u","a","e","i","o","u","n","-","","", "","","","","","","","","","","","","","a","e","i","o","u","","","","","", "","","","","","","","","","","","","a","e","i","o","u","a","e","i","o", "u","a","e","i","o","u","","a","e","i","o","u","-","","",""); 

         $temptitle = str_replace($b,$c,$temptitle);//TODO CARACTER DE $B QUE APAREZCA ES REMPLAZADO POR $C Y PUESTO EN $TEMPTITLE 

         $nombrearchivo .= rand(0,9) . rand(0,9) . rand(0,9). rand(0,9) . rand(0,9); //CONCATENA AL FINAL DEL ARCHIVO UN RANDOMIZE DE 5 DIGITOS DIFERENTES PARA DARLES UNA ID A CADA ARCHIVO Y QUE NO SE PISEN 

         $titulo = stripslashes($titulo); //ELIMINAMOS SLASHES 

         $nombrearchivo = $temptitle. '-';// PONE UNA BARRA MEDIA LUEGO DE TODA EL TITULO 

         $ext = '.php';//PONE TERMINACIÓN ".PHP" EN EL NOMBRE DEL ARCHIVO 

         $nombrearchivoext = $nombrearchivo . $ext; 
         //CREAMOS EL ARCHIVO 
         if (fopen($nombrearchivoext, 'w') == true) { 

          echo '<p id="exito">Se ha creado <b>'.$nombrearchivoext.'</b> Correctamente</p>'; 

          //ABRIMOS EL ARCHIVO Y LE METEMOS CONTENIDO 

          $fh = fopen($nombrearchivoext, 'w') or die("can't open file"); 

          $content = ' 
          <html> 
          <head> 
          <meta http-equiv="content-type" content="text/html" /> 
           <meta name="author" content="www.visualsac.net" /> 
           <link rel="stylesheet" type="text/css" href="style.css" /> 
           <title>'.$titulo.'</title> 
          </head> 
          <div class="body"> 
          <div class="global"> 
           <h1>Global</h1> 
           <h2>HOME</h2> 
            <? include("menubar.html")?> 
            <div>'.$titulo.'</div> 
            <p style="font-weight: bold ">'.$subtitle.'</p> 
            <p style="font-family:Seogue UI;">'.$texto.'</p> 
            </html> 

      '; 

         fwrite($fh,$content);// ESCRIBIMOS LOS DATOS EN EL ARCHIVO. PONEMOS LAS DOS CONDICIONES QUE PIDE 
         $user = 'localhost'; 
         $usuario = 'root'; 
         $pass = ''; 
         $tablename = 'noticias'; 
         $connect = mysql_connect($user, $root, $pass)or die(mysql_error()); 
          mysql_query("INSERT INTO $tablename values ('text','date','title','subtitle','image','type')") or die (mysql_error()); 


       }else { 
         $result = '<div class="result_fail">No se pudo crear el archivo <img src="http://web.tursos.com/wp-includes/      images/smilies/icon_sad.gif" alt=":(" class="wp-smiley"> </div>'; 

         }else { 
          echo"<p id='result_fail'>No puede exceder la cantidad especificada de caracteres. </p>"; 
           }      

       ?> 
       <form class='contacto' method='POST' action=''> 
        <div><label>Tipo de nota</label><select type=checkbox name='type' value='<?php $_POST['type'];?>'>         <option>Business<option>lifestyle<option>technology</select></div> 
        <div><label>Date:</label><input type=date class='date' name='date' value='<?php echo $_POST['date']; ?>'><?php echo      $error2 ?></div> 
        <div><label>subtitle:</label><input type='text' class='subtitle' name='subtitle' value='<?php echo         $_POST['subtitle']; ?>'><?php echo $error3 ?></div> 
        <div><label>Imagen:</label><input type='text' class='image' name='image' value='<?php echo $_POST['image']; ?>'> 
        <?php echo $error4 ?></div> 
        <div><label>Text:</label><textarea rows='6' class='text' name='text' value='<?php echo $_POST['text'];?>'><?php      echo $_POST['text']; ?></textarea><?php echo $error5 ?></div> 
        <div><input type='submit' value='Envia Mensaje' class='boton' name='boton'></div> 
        <?php echo $result; ?> 
       </form> 
    </body> 
    </html> 

回答

0

你有2个“其他” statment 1的代码在线路97的错误是一个它说:“如果”

}else { 
$result = '<div class="result_fail">No se pudo crear el archivo <img src="http://web.tursos.com/wp-includes/      images/smilies/icon_sad.gif" alt=":(" class="wp-smiley"> </div>'; 

}else { 
echo"<p id='result_fail'>No puede exceder la cantidad especificada de caracteres. </p>"; 
} 

如果你不会显示消息没有puede exceder la cantidad especificada de caracteres。 如果((strlen的($字幕)< = 75)& &(strlen的($ subtitulo)< = 75)& &(strlen的($ texto)< = 5000)== false,那么加上 “;” 到您的代码(不开始):

}else { 
$result = '<div class="result_fail">No se pudo crear el archivo <img src="http://web.tursos.com/wp-includes/      images/smilies/icon_sad.gif" alt=":(" class="wp-smiley"> </div>'; 

}**;** 
else { 
echo"<p id='result_fail'>No puede exceder la cantidad especificada de caracteres. </p>"; 
}