Jump to content

Recommended Posts

Hello, im trying to change my PHP code to be validated, with help of the W3C validator, I have now got a parse error as reads below...

 

Parse error: syntax error, unexpected T_VARIABLE in /misc/39/000/171/334/2/user/web/eaglelegend.com/index.php on line 42

 

here is the code...

 

<?
include("header.php");
?>
<h1>PLEASE NOTE</h1>
<p><strong>This site is in it's development stage! Please be patient as it should be finished up shortly!</strong></p>
<p>Welcome to Eagle Legend. From here you can create an account which will create your very own Virtual Pet.</p>
<p>Click <a href="http://www.eaglelegend.com/register.php">here</a> to get started today!</p>
<h2>Newest Adoptions</h2>
<br>
<table border="0" cellpadding="3" cellspacing="0" width="100%">
<tr>

  <?
  
     $sql = mysql_query("SELECT * FROM `pets` ORDER BY `id` DESC");
     while($row = mysql_fetch_array($sql)) {
      	extract($row);
      	$x=$x+1;
      	
      			if($status <= 3) {
			 	$s = "Very Unhappy";
			}
			if($status >= 3 && $status < 6) {
			 	$s = "Unhappy";
			}
			if($status >= 6 && $status < 9) {
			 	$s = "Bored";
			}
			if($status >= 9 && $status < 12) {
			 	$s = "Happy";
			}
			if($status >= 12 && $status < 15) {
			 	$s = "Very Happy";
			}
			if($status >= 15) {
			 	$s = "Very Happy and Playful!";
			}
	  
 	print "<td width='33%' valign='top'>
 	<table border=0 cellpadding=2 cellspacing=0 width=100%>
 	 <Tr>
 	  <Td valign=middle align=center><img src='/images/pets/$species.png' alt="$petName"></td>
 	  <td valign=top class=other width=100%>$user adopted a $species<br>
	   Name: $petName<br>Status: $s<br>Born: $date<br>Points: $points</td>
 	 </tr>
 	</table>
 	</td>";

	if($x%2==0) {
	 	print "</tr><Tr>";
	} 

    }
    
    print "</table>";
     ?>
<?
include("footer.php");
?>

 

The website is avalible on my "profile" also here www.eaglelegend.com or if you would like to take your time and copy

www.eaglelegend.com

and paste it in your address bar!

 

I have now solved that BUT it now I guess, "duplicates" it if you look at the site, I changed this code:

<Td valign=middle align=center><img src='/images/pets/$species.png' alt="$petName"></td>

 

to:

 

<Td valign=middle align=center><img src='/images/pets/$species.png' alt='$petName'></td>

 

any ideas?

Change

 

<?php

 	print "<td width='33%' valign='top'>
 	<table border=0 cellpadding=2 cellspacing=0 width=100%>
 	 <Tr>
 	  <Td valign=middle align=center><img src='/images/pets/$species.png' alt="$petName"></td>
 	  <td valign=top class=other width=100%>$user adopted a $species<br>
	   Name: $petName<br>Status: $s<br>Born: $date<br>Points: $points</td>
 	 </tr>
 	</table>
 	</td>";

 

To

<?php

 	print "<td width='33%' valign='top'>
 	<table border=0 cellpadding=2 cellspacing=0 width=100%>
 	 <Tr>
 	  <Td valign=middle align=center><img src='/images/pets/$species.png' alt=\"$petName\"></td>
 	  <td valign=top class=other width=100%>$user adopted a $species<br>
	   Name: $petName<br>Status: $s<br>Born: $date<br>Points: $points</td>
 	 </tr>
 	</table>
 	</td>";

 

You can't have double quotes within double quotes without escaping them.

change

<Td valign=middle align=center><img src='/images/pets/$species.png' alt="$petName"></td>

to

<Td valign=middle align=center><img src='/images/pets/$species.png' alt=\"$petName\"></td>

 

 

full here

<?
include("header.php");
?>
<h1>PLEASE NOTE</h1>
<p><strong>This site is in it's development stage! Please be patient as it should be finished up shortly!</strong></p>
<p>Welcome to Eagle Legend. From here you can create an account which will create your very own Virtual Pet.</p>
<p>Click <a href="http://www.eaglelegend.com/register.php">here</a> to get started today!</p>
<h2>Newest Adoptions</h2>
<br>
<table border="0" cellpadding="3" cellspacing="0" width="100%">
<tr>

  <?
  
     $sql = mysql_query("SELECT * FROM `pets` ORDER BY `id` DESC");
     while($row = mysql_fetch_array($sql)) {
      	extract($row);
      	$x=$x+1;
      	
      			if($status <= 3) {
			 	$s = "Very Unhappy";
			}
			if($status >= 3 && $status < 6) {
			 	$s = "Unhappy";
			}
			if($status >= 6 && $status < 9) {
			 	$s = "Bored";
			}
			if($status >= 9 && $status < 12) {
			 	$s = "Happy";
			}
			if($status >= 12 && $status < 15) {
			 	$s = "Very Happy";
			}
			if($status >= 15) {
			 	$s = "Very Happy and Playful!";
			}
	  
 	print "<td width='33%' valign='top'>
 	<table border=0 cellpadding=2 cellspacing=0 width=100%>
 	 <Tr>
 	  <Td valign=middle align=center><img src='/images/pets/$species.png' alt=\"$petName\"></td>
 	  <td valign=top class=other width=100%>$user adopted a $species<br>
	   Name: $petName<br>Status: $s<br>Born: $date<br>Points: $points</td>
 	 </tr>
 	</table>
 	</td>";

	if($x%2==0) {
	 	print "</tr><Tr>";
	} 

    }
    
    print "</table>";
     ?>
<?
include("footer.php");
?>

 

EDIT:Ahh pocobueno1388  beat me

Ok, I think I might know, its just im trying to have the site validated with HTML/XHTML site BUT it says certain "stuff" has to go infront :?

 

EDIT: SORRY, thanks guys, I found out why, I didnt delete the old code from the page, you see I copied the "repaired code" and pasted it, and didnt delete the old code before saving it then uploading it! thanks all!

 

 

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.