Foros del Web » Programando para Internet » PHP »

Error en codigo

Estas en el tema de Error en codigo en el foro de PHP en Foros del Web. Bien tengo un problemilla, encontre un php que me interesaba como era, pero no tenia el archivo para recibir los datos de la DB entonces ...
  #1 (permalink)  
Antiguo 04/03/2009, 08:28
 
Fecha de Ingreso: noviembre-2008
Mensajes: 29
Antigüedad: 15 años, 5 meses
Puntos: 0
Error en codigo

Bien tengo un problemilla, encontre un php que me interesaba como era, pero no tenia el archivo para recibir los datos de la DB entonces al inicio le añadí un trozo de código para que hiciera referencia al archivo donde estan los datos de la base de datos.
Pero luego me salta este error todo el rato:
Código:
Parse error: syntax error, unexpected '}' in /var/www/info/onlineplayers.php on line 6
Creo que hay bastantes varibles mal
onlineplayers.php

Código:
<?php
include("Connection.php");
//Do not remove this header
//This script package is distributed by kadar of L2j.sourceforge
//You are free to distribute this package as long as the headers stay intact. ?>
<?php }elseif($_GET['server']){ ?>
<table width="579" border="0" bgcolor="#2E6177" align="center" style="margin-bottom:15px;">
<tr bgcolor="#084360"><td colspan="6" align="center"><font color="#7C94B0"><b><?php echo $server_info['name']; ?></b></font></td></tr>
<tr bgcolor="#084360"><td width="23" align="center"><font color="#7C94B0"><b>#</b></font></td>
<td width="122" align="center"><font color="#7C94B0"><b>Name</b></font></td>
<td width="89" align="center"><font color="#7C94B0"><b>Race</b></font></td>
<td width="134" align="center"><font color="#7C94B0"><b>Class</b></font></td><td width="22" align="center"><font color="#7C94B0"><b>Lvl</b></font></td>
<td width="163" align="center"><font color="#7C94B0"><b>Location </b></font></td>
</tr>
<?php foreach($res_info as $res){ ?>
<tr bgcolor="#00192C"><td align="center"><?php echo $res['number']; ?></td>
<td><?php echo $res['name']; ?></td><td><?php echo $res["race"]; ?></td><td><?php echo $res["class"]; ?></td><td align="center"><?php echo $res['level']; ?></td>
<td><?php echo $res['pos']; ?></td></tr>
<?php } 
if(empty($res['number'])) echo '<tr bgcolor="#00192C"><td colspan="6" align="center"><b>Not there is Online Players</b></td></tr>';
?>
</table>
        
			  <?php } ?>
			</td>
			</tr>
	  </table>

Connection.php (archivo datos DB)

Código:
<?php

//Do not remove this header
//This script package is distributed by kadar of L2j.sourceforge
//You are free to distribute this package as long as the headers stay intact.
//
//This file must stay in the parent directory of the script folder
//and must be filled out correctly for the scripts to work.
//
//It is suggested to make a new user and pass for the scripts
//and set the permissions to select only.

$db_user = "root"; //your sql username goes here
$db_pass = "pass"; //your sql password goes here
$db_name = "l2jdb";    //your database name goes here
$db_serv = "localhost"; //the address of the database goes here
$db_port = "puerto"; //the address of the database goes here
$res = mysql_connect ( $db_serv, $db_user, $db_pass, $db_port ) or die ("Coudn't connect to [$db_serv]");
mysql_select_db ( $db_name );

?>
  #2 (permalink)  
Antiguo 04/03/2009, 08:33
Avatar de David
Moderador
 
Fecha de Ingreso: abril-2005
Ubicación: In this planet
Mensajes: 15.720
Antigüedad: 19 años
Puntos: 839
Respuesta: Error en codigo

El error es bastante claro, ¿por qué tienes esa llave ahí y por qué tienes elseif si no tienes un bloque if?
__________________
Por favor, antes de preguntar, revisa la Guía para realizar preguntas.
  #3 (permalink)  
Antiguo 04/03/2009, 08:49
 
Fecha de Ingreso: noviembre-2008
Mensajes: 29
Antigüedad: 15 años, 5 meses
Puntos: 0
Respuesta: Error en codigo

He modificado un poco el código del onlineplayers.php y me queda así:

Código:
<?php
include("Connection.php");
//Do not remove this header
//This script package is distributed by kadar of L2j.sourceforge
//You are free to distribute this package as long as the headers stay intact. ?>
<?php ($_GET['server']) ?>
<table width="579" border="0" bgcolor="#2E6177" align="center" style="margin-bottom:15px;">
<tr bgcolor="#084360"><td colspan="6" align="center"><font color="#7C94B0"><b><?php echo $server_info['name']; ?></b></font></td></tr>
<tr bgcolor="#084360"><td width="23" align="center"><font color="#7C94B0"><b>#</b></font></td>
<td width="122" align="center"><font color="#7C94B0"><b>Name</b></font></td>
<td width="89" align="center"><font color="#7C94B0"><b>Race</b></font></td>
<td width="134" align="center"><font color="#7C94B0"><b>Class</b></font></td><td width="22" align="center"><font color="#7C94B0"><b>Lvl</b></font></td>
<td width="163" align="center"><font color="#7C94B0"><b>Location </b></font></td>
</tr>
<tr bgcolor="#00192C"><td align="center"><?php echo $res['number']; ?></td>
<td><?php echo $res['name']; ?></td><td><?php echo $res["race"]; ?></td><td><?php echo $res["class"]; ?></td><td align="center"><?php echo $res['level']; ?></td>
<td><?php echo $res['pos']; ?></td></tr>
<?php 
echo $res['number']; echo '<tr bgcolor="#00192C"><td colspan="6" align="center"><b>Not there is Online Players</b></td></tr>';
?>
</table>

			</td>
			</tr>
	  </table>
Muestra online: 94.23.9.151/info/onlineplayers.php "añadir lo de http delante"

Como hago para que los datos de la base de datos se me muestren?

Última edición por wyrko; 04/03/2009 a las 08:56
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 05:17.