eaglelegend Posted April 3, 2008 Share Posted April 3, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/99378-solved-parse-error-syntax-error-unexpected-t_variable/ Share on other sites More sharing options...
pocobueno1388 Posted April 3, 2008 Share Posted April 3, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/99378-solved-parse-error-syntax-error-unexpected-t_variable/#findComment-508487 Share on other sites More sharing options...
MadTechie Posted April 3, 2008 Share Posted April 3, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/99378-solved-parse-error-syntax-error-unexpected-t_variable/#findComment-508488 Share on other sites More sharing options...
eaglelegend Posted April 3, 2008 Author Share Posted April 3, 2008 thanks guys, but the new problem is that it sort of "duplicated" inside the code if you know what I mean, best to look at my site to see what I mean... Quote Link to comment https://forums.phpfreaks.com/topic/99378-solved-parse-error-syntax-error-unexpected-t_variable/#findComment-508494 Share on other sites More sharing options...
pocobueno1388 Posted April 3, 2008 Share Posted April 3, 2008 You probably include the header.php file at the top of every page. So when you include another file within a script, it's calling that include again. Check and make sure thats not what's happening. Quote Link to comment https://forums.phpfreaks.com/topic/99378-solved-parse-error-syntax-error-unexpected-t_variable/#findComment-508498 Share on other sites More sharing options...
eaglelegend Posted April 3, 2008 Author Share Posted April 3, 2008 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! Quote Link to comment https://forums.phpfreaks.com/topic/99378-solved-parse-error-syntax-error-unexpected-t_variable/#findComment-508501 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.