Jump to content

$end error in script


TomFromKWD

Recommended Posts

Ok so I have one page with a set of links created with table data:

 

<a href="Aplayer.php?player='.$row['ID'].'">'.$row['fname'].' '.$row['lname'].'</a>

 

That link displays fine as the first name and last name in the table as it should and also when clicked goes on to Aplayer.php?player=1/2/3etc as it should.

 

However when it comes to loading the Aplayer.php with the appropriate ID action applied I get the following error:

 

Parse error: syntax error, unexpected $end in /home/a2552500/public_html/Aplayer.php on line 126

 

The codes for the Aplayer.php page is below, now I thought "unexpected $end" usually meant a '}' was missing, or incorrectly inserted in the code.

I must however be wrong due to the fact Ive checked for extra/missing '}'s and all seems ok.

 

Can someone skim through the following and point to me whats wrong, and a little explination would be nice where possible to ensure I dont make the same mistake in future.

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="content-type" content="text/html; charset=utf-8" />

<meta name="description" content="" />

<meta name="keywords" content="" />

<meta name="author" content="" />



<link rel="stylesheet" type="text/css" href="style.css" media="screen" />



<title>Yorkshire Leopards Cricket Club</title>



</head>



<body>









<div id="wrapper">
<? include('includes/sidebar.php'); ?>


<? include('includes/header.php'); ?>



<? include('includes/nav.php'); ?>





<div id="content">





<h2>Yorkshire Trust A<br>
<br></h2>
<?
session_start();
include "includes/dbconnect.php";
//retrieve the main article 
if(isset($_GET['ID'])){
$_SESSION['ID']=$_GET['ID'];
$getarticle="SELECT * FROM A_squad WHERE ID = ".$_GET['ID']." ";
if(!$result = mysql_query($getarticle)){
echo mysql_error();
}else{
$num=mysql_num_rows($result);
}
?>

<table width="100%" border="0">

	<? if(isset($num) && ($num > 0)){
	while($row_article=mysql_fetch_assoc($result)){
	?>
  <tr>
    <th align="left" width="18%" scope="row">Name:</th>
    <td width="24%"><? $_SESSION['fname']=$row_A_squad['fname'];
	  echo $_SESSION['fname'];?> <? $row_A_squad['lname'];?></td>
    <td width="58%" rowspan="6"><? $row_A_squad['img'];?></td>
  </tr>
  <tr>
    <th align="left" scope="row">Born:</th>
    <td><? $row_A_squad['born'];?></td>
    </tr>
  <tr>
    <th align="left" scope="row">Nicknames:</th>
    <td><? $row_A_squad['nickname'];?></td>
    </tr>
  <tr>
    <th align="left" scope="row">Batting Style:</th>
    <td><? $row_A_squad['bat_style'];?></td>
    </tr>
  <tr>
    <th align="left" scope="row">Bowling Style:</th>
    <td><? $row_A_squad['bowl_style'];?></td>
    </tr>
  <tr>
    <th align="left" scope="row">Bio:</th>
<td> </td>
</tr>
  <tr>
    <th align="left" scope="row"></th>
    <td height="200" colspan="2"><? $row_A_squad['bio'];?></td>
</tr>
</table>

</div>



<? include('includes/footer.php'); ?>



</div>



</body>



</html>

 

Thanks a bunch as always guys

 

Tom

Link to comment
Share on other sites

The last while(){ statement in the posted code is missing a closing } and the if(isset($_GET['ID'])){ line is missing it's closing }

 

Edit: and there seems to be at least one other one missing. Edit2: It was just those two that were missing.

 

I seriously recommend that you properly indent your code so that blocks at the same level are indented the same amount. This would get the {}'s to line up and you could find missing ones.

Link to comment
Share on other sites

its laid out fine in PSpad, just seems to be a bit funny once I ctrl+C/V'd it

 

part of the problem I spotted was I tried inserting <? } ?> like so at the end of the

 

.....    <th align="left" scope="row"></th>

    <td height="200" colspan="2"><? $row_A_squad['bio'];?></td>

</tr>

</table>

 

<? } ?>

 

When I actually needed

<?

      }

    }

?>

 

As I was closing off 2 strings.

 

I appreciate the help though, it was just one of those things where I couldnt see it until it was pointed out

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.