Foros del Web » Creando para Internet » Sistemas de gestión de contenidos » WordPress »

No funciona esta parte del código

Estas en el tema de No funciona esta parte del código en el foro de WordPress en Foros del Web. Saludos, estoy haciendo para que muestre unos posts, pero me da un error de Parse error: syntax error, unexpected T_ECHO, expecting ',' or ';' ¿Podéis ...
  #1 (permalink)  
Antiguo 04/12/2011, 07:05
 
Fecha de Ingreso: abril-2011
Mensajes: 72
Antigüedad: 13 años
Puntos: 4
Pregunta No funciona esta parte del código

Saludos, estoy haciendo para que muestre unos posts, pero me da un error de Parse error: syntax error, unexpected T_ECHO, expecting ',' or ';'


¿Podéis encontrar la perte en la questá el error? Gracias.

Código PHP:
<?php
    
endwhile;
  }
else { echo 
"<a href="echo($imagen1)"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=echo($imagen1)&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>  <a href="echo($imagen2)"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=echo($imagen2)&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>  <a href="echo($imagen3)"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=echo($imagen3)&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>  <a href="echo($imagen4)"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=echo($imagen4)&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>  <a href="echo($imagen5)"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=echo($imagen5)&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>"; }

?>
  #2 (permalink)  
Antiguo 04/12/2011, 07:08
Avatar de carlos_belisario
Colaborador
 
Fecha de Ingreso: abril-2010
Ubicación: Venezuela Maracay Aragua
Mensajes: 3.156
Antigüedad: 14 años
Puntos: 461
Respuesta: No funciona esta parte del código

que tanto conoces de PHP?? esto esta errado
Código PHP:
Ver original
  1. echo "<a href="echo($imagen1)"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=echo($imagen1)&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>  <a href="echo($imagen2)"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=echo($imagen2)&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>  <a href="echo($imagen3)"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=echo($imagen3)&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>  <a href="echo($imagen4)"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=echo($imagen4)&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>  <a href="echo($imagen5)"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=echo($imagen5)&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>"; }
  2. }
no puedes tener dos echo en la misma linea, ademas que el uso de las comillas esta errado, fijate aca hay una explicación de como se deben usar http://www.forosdelweb.com/f18/como-...1/#post2414268
__________________
aprende d tus errores e incrementa tu conocimientos
it's not a bug, it's an undocumented feature By @David
php the right way
  #3 (permalink)  
Antiguo 04/12/2011, 07:12
 
Fecha de Ingreso: abril-2011
Mensajes: 72
Antigüedad: 13 años
Puntos: 4
Respuesta: No funciona esta parte del código

¿Entonces cómo puedo solucionar ese código?

Gracias.
  #4 (permalink)  
Antiguo 04/12/2011, 07:15
 
Fecha de Ingreso: abril-2011
Mensajes: 72
Antigüedad: 13 años
Puntos: 4
Respuesta: No funciona esta parte del código

Estoy usando este código:

Código PHP:
Ver original
  1. <?php
  2. //for use in the loop, list 5 post titles related to first tag on current post
  3. $tags = wp_get_post_tags($post->ID);
  4. if ($tags) {
  5.   $first_tag = $tags[0]->term_id;
  6.   $args=array(
  7.     'tag__in' => array($first_tag),
  8.     'post_type' => reviews,
  9.     'post__not_in' => array($post->ID),
  10.     'showposts'=>10,
  11.     'caller_get_posts'=>1
  12.    );
  13.   $my_query = new WP_Query($args);
  14.   if( $my_query->have_posts() ) {
  15.     while ($my_query->have_posts()) : $my_query->the_post(); ?>
  16.       <p>
  17.  
  18.  
  19.        
  20.       <?php
  21. $juego = get_post_meta($post->ID, "Carátula del juego", true);
  22. $altura = get_post_meta($post->ID, "Tipo de carátula", true);
  23. $extracto = get_post_meta($post->ID, "Descripción", true);
  24. ?>
  25.  
  26. <div class="juego-item"><div class="thumbd"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" alt="<?php the_title(); ?>"><img src="<?php echo($juego) ?>" align="left" class="<?php echo($altura) ?>" title="<?php the_title(); ?>" alt="<?php the_title(); ?>"></a></div>
  27.  
  28. <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
  29. <div class="entry-content">
  30. <?php echo($extracto); ?>
  31. </div>
  32. </div>
  33.     <?php
  34.     endwhile;
  35.   }
  36. else { echo ""; }
  37. }
  38. ?>


Y me gustaría meter en el "else {echo}" este código:

<a href="<?php echo($imagen1) ?>"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=<?php echo($imagen1) ?>&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a> <a href="<?php echo($imagen2) ?>"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=<?php echo($imagen2) ?>&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a> <a href="<?php echo($imagen3) ?>"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=<?php echo($imagen3) ?>&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a> <a href="<?php echo($imagen4) ?>"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=<?php echo($imagen4) ?>&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a> <a href="<?php echo($imagen5) ?>"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=<?php echo($imagen5) ?>&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>
  #5 (permalink)  
Antiguo 04/12/2011, 07:18
Avatar de carlos_belisario
Colaborador
 
Fecha de Ingreso: abril-2010
Ubicación: Venezuela Maracay Aragua
Mensajes: 3.156
Antigüedad: 14 años
Puntos: 461
Respuesta: No funciona esta parte del código

leiste la referencia que te deje?? porque ahí te dice como hacer las cosas bien con las comillas, además de lo primero que te indique que no puedes tener dos echo en la misma linea de codigo, debería de quedarte algo parecido a esto

Código PHP:
Ver original
  1. echo "<a href=/"$tuvariable/">lo que sea que pongas en el link</a>";
__________________
aprende d tus errores e incrementa tu conocimientos
it's not a bug, it's an undocumented feature By @David
php the right way
  #6 (permalink)  
Antiguo 04/12/2011, 07:24
 
Fecha de Ingreso: abril-2011
Mensajes: 72
Antigüedad: 13 años
Puntos: 4
Respuesta: No funciona esta parte del código

He modificado el código como me has dicho, pero sigue sin funcionar:


Código PHP:
Ver original
  1. <?php
  2.     endwhile;
  3.   }
  4. else { echo "<a href="$imagen1"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=$imagen1&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>";  <a href="$imagen2"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=$imagen2&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>";  <a href="$imagen3"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=$imagen3&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>";  <a href="$imagen4"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=$imagen4&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>";  <a href="$imagen5"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=$imagen5&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>"; }
  5. }
  6. ?>
  #7 (permalink)  
Antiguo 04/12/2011, 07:50
Avatar de carlos_belisario
Colaborador
 
Fecha de Ingreso: abril-2010
Ubicación: Venezuela Maracay Aragua
Mensajes: 3.156
Antigüedad: 14 años
Puntos: 461
Respuesta: No funciona esta parte del código

como te dije amigo debes de ver la referencia de como usar las comillas bien el problema es que no las estas escapando y por eso es que te da el error, fijate la barra invertida que coloque adelante de las comillas en el ejemplo que te puse, eso la escapa de tal manera que la interprete como una comilla y no como el cierre de la cadena a imprimir, pero como te indique en la referencia que te deje en el link el amigo pateketrueke hace una explicación completa del como utilizar las comillas con el PHP, sería bueno que vieras la referencia de tal manera que aprendas un poco mas del lenguaje, saludos
__________________
aprende d tus errores e incrementa tu conocimientos
it's not a bug, it's an undocumented feature By @David
php the right way
  #8 (permalink)  
Antiguo 04/12/2011, 07:57
 
Fecha de Ingreso: abril-2011
Mensajes: 72
Antigüedad: 13 años
Puntos: 4
Respuesta: No funciona esta parte del código

Y en la parte del código de la imagen:

<img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=$imagen2&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150">

¿También he de escaparlas?
  #9 (permalink)  
Antiguo 04/12/2011, 08:00
 
Fecha de Ingreso: abril-2011
Mensajes: 72
Antigüedad: 13 años
Puntos: 4
Problema con uso de HEREDOC

He usado tu código, pero sigue sin funcionar:

Código PHP:
Ver original
  1. <?php
  2. //for use in the loop, list 5 post titles related to first tag on current post
  3. $tags = wp_get_post_tags($post->ID);
  4. if ($tags) {
  5.   $first_tag = $tags[0]->term_id;
  6.   $args=array(
  7.     'tag__in' => array($first_tag),
  8.     'post_type' => reviews,
  9.     'post__not_in' => array($post->ID),
  10.     'showposts'=>10,
  11.     'caller_get_posts'=>1
  12.    );
  13.   $my_query = new WP_Query($args);
  14.   if( $my_query->have_posts() ) {
  15.     while ($my_query->have_posts()) : $my_query->the_post(); ?>
  16.       <p>
  17.  
  18.  
  19.        
  20.       <?php
  21. $juego = get_post_meta($post->ID, "Carátula del juego", true);
  22. $altura = get_post_meta($post->ID, "Tipo de carátula", true);
  23. $extracto = get_post_meta($post->ID, "Descripción", true);
  24. ?>
  25.  
  26. <div class="juego-item"><div class="thumbd"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" alt="<?php the_title(); ?>"><img src="<?php echo($juego) ?>" align="left" class="<?php echo($altura) ?>" title="<?php the_title(); ?>" alt="<?php the_title(); ?>"></a></div>
  27.  
  28. <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
  29. <div class="entry-content">
  30. <?php echo($extracto); ?>
  31. </div>
  32. </div>
  33.     <?php
  34.     endwhile;
  35.   }
  36. else { echo "<a href=/"$imagen1/"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=/$imagen1/&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>";  <a href=/"$imagen2/"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=/$imagen2/&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>";  <a href=/"$imagen3/"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=/$imagen3/&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>";  <a href=/"$imagen4/"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=/$imagen4/&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>";  <a href=/"$imagen5/"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=/$imagen5/&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>"; }
  37. }
  38. ?>
  39. </p>


Saludos y gracias.
  #10 (permalink)  
Antiguo 04/12/2011, 08:03
 
Fecha de Ingreso: noviembre-2011
Mensajes: 516
Antigüedad: 12 años, 5 meses
Puntos: 10
Respuesta: COMO: usar las comillas bien

Esta muy bien ami me pasa que nose cual comillas usar y si las tengo que usar esta perfecto gracias por el aporte.
  #11 (permalink)  
Antiguo 04/12/2011, 08:41
Avatar de charlyalegret  
Fecha de Ingreso: septiembre-2011
Ubicación: Barcelona
Mensajes: 705
Antigüedad: 12 años, 7 meses
Puntos: 140
Respuesta: COMO: usar las comillas bien

Cita:
Iniciado por javierm5 Ver Mensaje
He usado tu código, pero sigue sin funcionar:
Estaría bien saber dónde te salta el error.

Yo lo que veo es que en el echo final has de escapar las comillas, has de usar \" (no /") y escaparlas todas. En este caso, si sólo usas variables (no arrays), las dejas tal cual, no hace falta poner comillas... por otro lado, teniendo tanto código por ahí, puedes usar también:

echo <<<END

Aquí todo el código, las variables php entre corchetes

END; (sin ningun espacio por delante)

Más información consulta el manual: http://php.net/manual/es/function.echo.php

Además si utilizas para escribir un programa como Notepad++, verás enseguida los errores por la coloración del código...

Suerte
  #12 (permalink)  
Antiguo 04/12/2011, 09:03
 
Fecha de Ingreso: abril-2011
Mensajes: 72
Antigüedad: 13 años
Puntos: 4
Respuesta: COMO: usar las comillas bien

¿así?


Código PHP:
else { echo <<<END "<a href=[$imagen1]><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=[$imagen1]&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>";  <a href=[$imagen2]><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=[$imagen2]&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>";  <a href=[$imagen3]><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=[$imagen3]&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>";  <a href=[$imagen4]><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=[$imagen4]&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>";  <a href=[$imagen5]><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=[$imagen5]&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>"; END; } 

?> 
  #13 (permalink)  
Antiguo 04/12/2011, 09:24
Avatar de charlyalegret  
Fecha de Ingreso: septiembre-2011
Ubicación: Barcelona
Mensajes: 705
Antigüedad: 12 años, 7 meses
Puntos: 140
Respuesta: COMO: usar las comillas bien

No
1ero: debe ser en varias lineas...:

echo <<<END
en las siguientes lineas el código
END; ESTA LINEA DEBE ESTAR Sóla y sin ningún espacio por delante

Además, corchetes me refería a { no ha [ (perdón no se como se llaman...)
Además, debes poner href=" aquí esto va con comillas!!

Suerte!
  #14 (permalink)  
Antiguo 05/12/2011, 06:27
Avatar de Nekko
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Buenos Aires
Mensajes: 3.141
Antigüedad: 16 años, 1 mes
Puntos: 656
Respuesta: No funciona esta parte del código

Que choclo de código!!!

Fijate de este modo y si no funciona (cosa que seguramente pase), empezá a buscar el error que surja dentro del código generado. Ahora hay que ver si esas variables contienen exactamente lo que necesitás.

Igualmente lo que Carlos_belisario te está diciendo, es que leas sobre el uso de las comillas y utilices eso para corregir tu propio código. Mientras mas aprendas vos sobre el tema, mas fácil te va a ser corregir este asunto. Nosotros podemos sugerirte cambios, pero de acá a que funcione, hay un largo camino y muchas pruebas en el medio.

Código PHP:
Ver original
  1. else { echo '<a href="'.$imagen1.'"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src='.$imagen1.'&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>";  <a href="'.$imagen2.'"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src='.$imagen2.'&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>";  <a href="'.$imagen3.'"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src='.$imagen3.'&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>";  <a href="'.$imagen4.'"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=$imagen4&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>";  <a href="'.$imagen5.'"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src='.$imagen5.'&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>'; }
__________________
Taller para crear themes wordpress desde cero | Presupuestos para trabajos particulares vía MP
  #15 (permalink)  
Antiguo 05/12/2011, 06:28
 
Fecha de Ingreso: abril-2011
Mensajes: 72
Antigüedad: 13 años
Puntos: 4
Respuesta: COMO: usar las comillas bien

Llevo un rato intentando corregirlo, es que de PHP se poco.

¿Así?

Código PHP:
<?php
    
endwhile;
  }
else { echo <<<
END 
"<a href="{$imagen1}"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src={$imagen1}&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>";  <a href="{$imagen2}"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src={$imagen2}&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>";  <a href="{$imagen3}"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src={$imagen3}&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>";  <a href="{$imagen4}"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src={$imagen4}&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>";  <a href="{$imagen5}"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src={$imagen5}&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>";}  
END;
}
?>
  #16 (permalink)  
Antiguo 05/12/2011, 06:57
Avatar de charlyalegret  
Fecha de Ingreso: septiembre-2011
Ubicación: Barcelona
Mensajes: 705
Antigüedad: 12 años, 7 meses
Puntos: 140
Respuesta: COMO: usar las comillas bien

Prueba así, y mira el resultado html a ver que te sale...:

Código PHP:
Ver original
  1. <?php
  2.     endwhile;
  3.   }
  4. else {
  5. echo <<<END
  6. <a href="{$imagen1}"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src={$imagen1}&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>";  <a href="{$imagen2}"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src={$imagen2}&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>";  <a href="{$imagen3}"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src={$imagen3}&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>";  <a href="{$imagen4}"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src={$imagen4}&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>";  <a href="{$imagen5}"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src={$imagen5}&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>
  7. END;
  8. }
  9. ?>
  #17 (permalink)  
Antiguo 05/12/2011, 07:22
 
Fecha de Ingreso: abril-2011
Mensajes: 72
Antigüedad: 13 años
Puntos: 4
Respuesta: COMO: usar las comillas bien

Da error en la líne 268:


echo <<<END
  #18 (permalink)  
Antiguo 05/12/2011, 08:04
Avatar de charlyalegret  
Fecha de Ingreso: septiembre-2011
Ubicación: Barcelona
Mensajes: 705
Antigüedad: 12 años, 7 meses
Puntos: 140
Respuesta: COMO: usar las comillas bien

he mirado la linea con más detenimiento (es muy larga y no lo había hecho antes). hay varios errores, ya que tienes 5 <a> y las acababas con "; ... (sólo se lo quité a la última)

puedes usar (a mi me funciona así... importante con el copypaste, que el END; final te quede solo sin espacios delante):

Código PHP:
Ver original
  1. <?php
  2. endwhile;
  3.       }
  4.     else {
  5.     echo <<<END
  6.     <a href="{$imagen1}"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src={$imagen1}&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a><a href="{$imagen2}"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src={$imagen2}&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>  <a href="{$imagen3}"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src={$imagen3}&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>  <a href="{$imagen4}"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src={$imagen4}&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>  <a href="{$imagen5}"><img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src={$imagen5}&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>
  7. END;
  8.     }
  9.     ?>

o bien con comillas dobles y escapándolas:

Código PHP:
Ver original
  1. <?php
  2. endwhile;
  3.       }
  4.     else {
  5. echo "<a href=\"$imagen1\"><img src=\"http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=$imagen1&h=150&w=150&zc=1&q=100&cropfrom=center\" align=\"left\" class=\"alignnone size-thumbnail galeria\" height=\"150\" width=\"150\"></a><a href=\"$imagen2\"><img src=\"http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=$imagen2&h=150&w=150&zc=1&q=100&cropfrom=center\" align=\"left\" class=\"alignnone size-thumbnail galeria\" height=\"150\" width=\"150\"></a><a href=\"$imagen3\"><img src=\"http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=$imagen3&h=150&w=150&zc=1&q=100&cropfrom=center\" align=\"left\" class=\"alignnone size-thumbnail galeria\" height=\"150\" width=\"150\"></a><a href=\"$imagen4\"><img src=\"http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=$imagen4&h=150&w=150&zc=1&q=100&cropfrom=center\" align=\"left\" class=\"alignnone size-thumbnail galeria\" height=\"150\" width=\"150\"></a><a href=\"$imagen5\"><img src=\"http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=$imagen5&h=150&w=150&zc=1&q=100&cropfrom=center\" align=\"left\" class=\"alignnone size-thumbnail galeria\" height=\"150\" width=\"150\"></a>";
  6.     }
  7.     ?>

Saludos!
  #19 (permalink)  
Antiguo 05/12/2011, 08:14
 
Fecha de Ingreso: abril-2011
Mensajes: 72
Antigüedad: 13 años
Puntos: 4
Respuesta: COMO: usar las comillas bien

Gracias, parece que va funcionando, ahora me da un error de

Parse error: syntax error, unexpected $end

En la última línea del código de la palntilla:

<?php get_template_part('content', 'after'); ?>
  #20 (permalink)  
Antiguo 05/12/2011, 08:29
Avatar de charlyalegret  
Fecha de Ingreso: septiembre-2011
Ubicación: Barcelona
Mensajes: 705
Antigüedad: 12 años, 7 meses
Puntos: 140
Respuesta: COMO: usar las comillas bien

ups, esto me parece que es algo de wordpress? ahí no te puedo ayudar. te recomiendo pedir que te muevan a otro hilo, ya que este es sobre comillas... y que incluyas la linea anterior, ya que muchas veces el error está en la linea anterior pero el warning te dice la siguiente linea, en la que espera algo que no encontraba (como definir variable sin acabar con ;). Saludos
  #21 (permalink)  
Antiguo 05/12/2011, 08:39
 
Fecha de Ingreso: abril-2011
Mensajes: 72
Antigüedad: 13 años
Puntos: 4
Respuesta: COMO: usar las comillas bien

Según he leído, el error es de que falta cerrar un corchete en el código.

Gracias por tu ayuda.
  #22 (permalink)  
Antiguo 05/12/2011, 10:24
 
Fecha de Ingreso: abril-2011
Mensajes: 72
Antigüedad: 13 años
Puntos: 4
Respuesta: No funciona esta parte del código

¡¡¡Solucionado!!! El código de Nekko funciona perfectamente, pero lo corrijo un poco:


Código PHP:
Ver original
  1. <img src="http://www.actualidadconsolas.com/wp-content/themes/GamerAC/scripts/timthumb.php?src=[B]$imagen4[/B]&h=150&w=150&zc=1&q=100&cropfrom=center" align="left" class="alignnone size-thumbnail galeria" height="150" width="150"></a>

En negro te olvidaste el '.

Y luego, que después de cada </a>, no hace falta poner ;, porque sale como carácter.


Muchísimas gracias por tu ayuda, +1. ¡Eres un as!
  #23 (permalink)  
Antiguo 05/12/2011, 10:29
Avatar de Nekko
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Buenos Aires
Mensajes: 3.141
Antigüedad: 16 años, 1 mes
Puntos: 656
Respuesta: No funciona esta parte del código

Muy bueno! Lo importante es que entendiste mejor cómo es la sintaxis y de ese modo aprendiste a corregirlo vos mismo!
__________________
Taller para crear themes wordpress desde cero | Presupuestos para trabajos particulares vía MP

Etiquetas: php, post, themes
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:04.