Jump to content

PHP If Statement Problem


usadarts

Recommended Posts

I am getting the following error with this code:

Parse error: parse error, unexpected $ in /home/hascupd/public_html/template.php on line 270

 

Line 270 is the last line of the code........I do not believe that is actually the problem.  I believe the problem lies on how I have the if().

 

 

                            <?php
$dbh=mysql_connect ("local", "database", "password") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("points"); 

$querym = "SELECT * FROM 2007 ORDER BY `natpts` DESC";
$resultm = mysql_query($querym,$dbh) or die(mysql_error());

$results_headerm =<<<HEADERm
<table cellspacing='1' align="center">

HEADERm;
$rank = 0;

while($row = mysql_fetch_array($resultm))
{
    $rank = $rank + 1;
    $name = $row['lastname'];
    $assoc = $row['assoc'];
    $points = $row['natpts'];


if($assoc == "USAD"){
$results_detailsm .=<<<DETAILSm
<tr>

<td align="left"><font size="-1">$rank</font>. </td>
<td><font size="-1">$name</font></td>
<td align="right"><font size="-1">$points</font></td>

</tr>
DETAILSm;
}

}

$results_footerm ="</table>";

echo $results_headerm;
    echo $results_detailsm;
echo $results_footerm;
?>

Link to comment
https://forums.phpfreaks.com/topic/46473-php-if-statement-problem/
Share on other sites

The ending of a HEREDOC element MUST start at the beginning of the line. Change:

<?php
$results_detailsm .=<<<DETAILSm
<tr>

<td align="left"><font size="-1">$rank</font>. </td>
<td><font size="-1">$name</font></td>
<td align="right"><font size="-1">$points</font></td>

</tr>
DETAILSm;
?>

to

<?php
$results_detailsm .=<<<DETAILSm
<tr>

<td align="left"><font size="-1">$rank</font>. </td>
<td><font size="-1">$name</font></td>
<td align="right"><font size="-1">$points</font></td>

</tr>
DETAILSm;
?>

 

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.