Error !!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
burnhallian
Forum Commoner
Posts: 28
Joined: Tue Jul 12, 2005 2:47 am

Error !!

Post by burnhallian »

hi guyz !!

hey i gotta problem in thisone.. i know its simple but what to do ?? :(

the code is below, im viewing a radio button, plzz tell me what am i missing.

Code: Select all

echo '<tr><td>
if ($row['5'] == sig) { echo "Significant Breakthrough"; }
elseif ($row['5'] == maj) { echo "Major Breakthrough"; }
elseif ($row['5'] == min) { echo "Minor Breakthrough"; }
</td></tr>';
The error it gives is:

Parse error: parse error, unexpected T_LNUMBER, expecting ',' or ';' in /usr/local/apache/htdocs/pcrs/kma.php on line 79
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Code: Select all

echo '<tr><td>
if ($row['5
As you can see with the sourcecode highlight, you can see the string ends at ' and then a 5 follows... It makes php complain :)

Anyway, http://www.php.net/string will tell you more about how you can make strings (with quotes in them)
User avatar
burnhallian
Forum Commoner
Posts: 28
Joined: Tue Jul 12, 2005 2:47 am

Post by burnhallian »

So what should i do ? i tried to remove the ' from ['5'] but then i get the ouput as

if ($row[5] == sig) { echo "Significant Breakthrough"; } elseif ($row[5] == maj) { echo "Major Breakthrough"; } elseif ($row[5] == min) { echo "Minor Breakthrough"; }

not the values that i wanted for the radio button..plzz help
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the error doesn't lie in the '5', it lies in the line before it, where you didn't stop the string, let alone the statement.
User avatar
burnhallian
Forum Commoner
Posts: 28
Joined: Tue Jul 12, 2005 2:47 am

Post by burnhallian »

but i have already done that. the code is below, kindly go through it :)

Code: Select all

$query="SELECT * FROM objective WHERE hw_id={$_GET['ll']}";
$result=@mysql_query($query);
while($row=mysql_fetch_array($result,MYSQL_NUM))
{
$row[2]=nl2br($row[2]);
$row[4]=nl2br($row[4]);
$row[5]=nl2br($row[5]);
$row[6]=nl2br($row[6]);
$row[7]=nl2br($row[7]);


echo '<table border="1" bgcolor="#d0e5da" >';
echo '<tr><td><b>OBJECTIVE ACHIEVEMENT</b></td>';
echo '<tr><td><b>1. Original Project Achievement</b></td></tr>';
echo "<tr><td>{$row['1']}</td></tr>";
echo '<tr><td><b>2. Objectives Achieved</b></td></tr>';
echo "<tr><td>{$row['2']}</td></tr>";
echo '<tr><td><b>3. Objectives not Achieved</b></td></tr>';
echo "<tr><td>{$row['3']}</td></tr>";
echo '<tr><td><b>4. Indicators for achievement of objectives</b></td></tr>';
echo "<tr><td>{$row['4']}</td></tr>";
echo '<tr><td><b>5. How would you characterize the quality of this output ?</b></td></tr>';
echo "<tr><td>{$row['5']}</td></tr>";




echo "<tr><td>
if ($row['5'] == sig) { echo "Significant Breakthrough"; }
elseif ($row['5'] == maj) { echo "Major Breakthrough"; }
elseif ($row['5'] == min) { echo "Minor Breakthrough"; }
</td></tr>";
mickd
Forum Contributor
Posts: 397
Joined: Tue Jun 21, 2005 9:05 am
Location: Australia

Post by mickd »

Code: Select all

echo "<tr><td>
if ($row['5'] == sig) { echo "Significant Breakthrough"; }
elseif ($row['5'] == maj) { echo "Major Breakthrough"; }
elseif ($row['5'] == min) { echo "Minor Breakthrough"; }
</td></tr>";
the problem above is that you didnt end the string on the first line.

Code: Select all

echo '<tr><td>'; // ends the string
if ($row[5] == 'sig') { echo 'Significant Breakthrough'; }
elseif ($row[5] == 'maj') { echo 'Major Breakthrough'; }
elseif ($row[5] == 'min') { echo 'Minor Breakthrough'; }
echo '</td></tr>'; //start another echo to output the closing stuff.
i believe your array usage was incorrect also as you had an integer quoted (maybe intentional).
you also didnt have sig, maj and min quoted.
User avatar
burnhallian
Forum Commoner
Posts: 28
Joined: Tue Jul 12, 2005 2:47 am

Post by burnhallian »

thanx buddy ! it worked ... u r cool man :D
Post Reply