Foros del Web » Programando para Internet » PHP »

Necesito ayuda con este código.

Estas en el tema de Necesito ayuda con este código. en el foro de PHP en Foros del Web. Buenas tardes. Estoy pasando una validación W3C XHTML y me da errores, aunque funciona perfectamente. Casi todo viene de un módulo PHP que tengo para ...
  #1 (permalink)  
Antiguo 22/02/2007, 08:46
 
Fecha de Ingreso: junio-2006
Ubicación: Madrid - España
Mensajes: 179
Antigüedad: 17 años, 10 meses
Puntos: 6
Necesito ayuda con este código.

Buenas tardes. Estoy pasando una validación W3C XHTML y me da errores, aunque funciona perfectamente. Casi todo viene de un módulo PHP que tengo para que me muestro los juegos de forma aleatoria en la página de inicio. El código PHP de ese módulo es:

<?php
/**
* @version 1.0 $
* @package SMFArcadeRandom
* @copyright (C) 2005 Melissa Padilla
*
* This module assumes Simple Machines Forum (SMF) is installed, functioning and running wrapped in mambo with
* the mos-smf bridge. This module also assumes that smf_arcade is installed in SMF and functioning already.
*
*/

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

global $database, $smf_prefix, $mosConfig_absolute_path, $boardurl;

//require($mosConfig_absolute_path . "/administrator/components/com_smf/config.smf.php");

// Retrieve module parameters or set defaults if module parameters empty
$count = intval( $params->get( 'count', 5 ) );
$noscore = $params->get( 'noscore', 'No Scores Yet');
$topscore = $params->get( 'topscore', 'Top Scores');
$gamefolder = $params->get( 'gamefolder', 'Games');
$show_thumb = $params->get('show_thumb', 'yes');
$show_game_name = $params->get('show_game_name', 'yes');
$show_scores = $params->get('show_scores', 'yes');
$ext = array('gif','GIF','png','PNG','jpg','JPG',); // Extensions to look for
$game_id = intval( $params->get( 'game_id', 55) );
// Load a random game
$query = "SELECT DISTINCT id , game, name, thumb FROM smf_games order by RAND() LIMIT 1";
$database ->setQuery("SELECT DISTINCT id , game, name FROM smf_games ORDER BY RAND() LIMIT 1");
$results = $database->loadObjectList();

//if ($result = $database->query()) {
// $row = mysql_fetch_object($result);
// $smfItemid = $row->id;
//}
//else {
// echo "Error fetching smfItemid: ".mysql_errno()." ".mysql_error();
// return false;
//}
foreach($results as $row){
// Build table with game thumbnail, title and link to arcade for playing
echo "<table border=\"0\" align=\"center\">";

if (strcasecmp($show_thumb, "yes") == 0){
// Set thumbnail of the random game selected above
$thumb = $boardurl. "/" .$gamefolder."/".$row->game.".gif";
echo "<tr><td colspan=\"2\" align=\"center\"><a href=\"index.php?option=com_smf&Itemid=" . $game_id . "&action=arcade;sa=play;game=" . $row->id . "\"><img src=\"$thumb\" border=\"0\"/></a></td></tr>";
}

if (strcasecmp($show_game_name, "yes") == 0){
// Set game name as link
echo "<tr><td colspan=\"2\" align=\"center\"><a href=\"index.php?option=com_smf&Itemid=". $game_id . "&action=arcade;sa=play;game=" . $row->id . "\">$row->name</a><br></td></tr>";
}

if (strcasecmp($show_scores, "yes") == 0){
// Retrieve highscores for the random game selected above based on 'count' module parameter
$query2 = "Select game, member, score, smf_members.ID_MEMBER, smf_members.realName from smf_games_high, smf_members WHERE game = '$row->game' AND smf_members.ID_MEMBER = smf_games_high.member ORDER BY score DESC LIMIT {$count}";
$database->setQuery("Select game, member, score, smf_members.ID_MEMBER, smf_members.realName from smf_games_high, smf_members WHERE game = '$row->game' AND smf_members.ID_MEMBER = smf_games_high.member ORDER BY score DESC LIMIT {$count}");
$HSrows = $database->loadObjectList();
$HSrow=$HSrows[0];

//Build last 'count' highscore rows or set to 'noscore' if no scores yet
if (!isset($HSrow->realName)){
echo "<tr><td colspan=\"2\" align=\"center\">" . $noscore . "</td></tr>";
}else{
echo "<tr><td colspan=\"2\" align=\"center\">" . $count . " " . $topscore . "</td></tr>";
foreach($HSrows as $HSrow){
echo "<tr ><td width='60%' class='sectiontableentry2'>" . $HSrow->realName . "</td><td width='40%' align='right' class='sectiontableentry2'>" . (float)$HSrow->score . "</td></tr>";
}
}
}
}

echo "</table>";

?>


Se que hay cosas que están mal, pero he hecho pruebas y no consigo averiguar cual es.

La parte en rojo, es la que creo, la que produce los fallos.

Si alguien puede /sabe ayudarme le estaré agradecido. Mi sitio es malastic . com.

Un saludo,
  #2 (permalink)  
Antiguo 22/02/2007, 12:03
Avatar de Nefertiter  
Fecha de Ingreso: enero-2003
Ubicación: Rosario
Mensajes: 1.316
Antigüedad: 21 años, 4 meses
Puntos: 9
Re: Necesito ayuda con este código.

Cita:
La parte en rojo, es la que creo, la que produce los fallos.
yo veo todo en negro, xq no adjuntas los errores que te tira el interprete?
  #3 (permalink)  
Antiguo 22/02/2007, 13:27
Avatar de AlZuwaga
Colaborador
 
Fecha de Ingreso: febrero-2001
Ubicación: 34.517 S, 58.500 O
Mensajes: 14.550
Antigüedad: 23 años, 2 meses
Puntos: 535
Re: Necesito ayuda con este código.

click aquí para ver la parte en rojo...
__________________
...___...
  #4 (permalink)  
Antiguo 22/02/2007, 13:53
 
Fecha de Ingreso: enero-2006
Ubicación: Madrid
Mensajes: 74
Antigüedad: 18 años, 3 meses
Puntos: 2
Re: Necesito ayuda con este código.

sería más sencillo si nos dieras también el html resultante, que el fin y al cabo es lo que "valida" o no "valida", así podríamos ver mejor dónde están los errores (me figuro que dentro de los "echo" que te generan esas tablas) :O); o, directamente, como dice Nefertiter, los fallos que te da el validador.
  #5 (permalink)  
Antiguo 22/02/2007, 17:07
Avatar de jam1138
/** @package Moderador */
 
Fecha de Ingreso: julio-2004
Ubicación: sèveR led onieR lE
Mensajes: 9.368
Antigüedad: 19 años, 9 meses
Puntos: 102
Re: Necesito ayuda con este código.

En definitiva no es un problema de PHP y dicho código (PHP) solo hace ruido.

Cerrado por duplicado, continua en http://www.forosdelweb.com/showthread.php?t=467182

Políticas de Foros del Web
__________________
٩(͡๏̯͡๏)۶
» Cómo hacer preguntas de manera inteligente «

"100 años después, la revolución no es con armas, es intelectual y digital"
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.
Tema Cerrado




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