Page 1 of 1

Error !!

Posted: Wed Jan 11, 2006 9:15 pm
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

Posted: Wed Jan 11, 2006 9:23 pm
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)

Posted: Wed Jan 11, 2006 9:49 pm
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

Posted: Wed Jan 11, 2006 10:07 pm
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.

Posted: Thu Jan 12, 2006 12:02 am
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>";

Posted: Thu Jan 12, 2006 12:11 am
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.

Posted: Thu Jan 12, 2006 12:21 am
by burnhallian
thanx buddy ! it worked ... u r cool man :D