BigX Posted June 9, 2008 Share Posted June 9, 2008 Hi, I got the following code: <tr> <td width='250' align='left' style='font-size: 17px' bgcolor='#FFFFFF'><u><b>Eindstand Poule</b></u></td> <td width='100' align='left' style='color: #CC0000' style='font-size: 14px' bgcolor='#FFFFFF'><b> </b></td> <td width='100' align='left' style='color: #CC0000' style='font-size: 14px' bgcolor='#FFFFFF'><b> </b></td> </tr>"; echo $row['1e_poule_a']; echo " <tr> <td width='250' align='left' style='font-size: 14px' bgcolor='#FFFFFF'><b>$row[ZWI_TSJ_uitslag]</b></td> <td width='100' align='left' style='color: #CC0000' style='font-size: 14px' bgcolor='#FFFFFF'><b> </b></td> <td width='100' align='left' style='color: #CC0000' style='font-size: 14px' bgcolor='#FFFFFF'><b> </b></td> </tr> <tr> <td width='250' align='left' style='font-size: 14px' bgcolor='#FFFFFF'><b>$row[1e_poule_a]</b></td> <td width='100' align='left' style='color: #CC0000' style='font-size: 14px' bgcolor='#FFFFFF'><b> </b></td> <td width='100' align='left' style='color: #CC0000' style='font-size: 14px' bgcolor='#FFFFFF'><b> </b></td> </tr> the echo $row['1e_poule_a']; part in the middle works and gives a good echo!! >$row[ZWI_TSJ_uitslag]< in the table works fine But the >$row[1e_poule_a]< gives back an error!?!? Why is that? the sum of these three things seem verystrange to me but maybe this is something simple!! Thanx Link to comment https://forums.phpfreaks.com/topic/109357-syntax-error/ Share on other sites More sharing options...
Lumio Posted June 9, 2008 Share Posted June 9, 2008 When you using an array in "" you have to write "{$array['index']}". But I won't use that in this way. Better to output HTML as HTML and not with PHP: <table> <tr> <td><?php echo time(); ?></td> </tr> </table> Link to comment https://forums.phpfreaks.com/topic/109357-syntax-error/#findComment-560916 Share on other sites More sharing options...
tapos Posted June 9, 2008 Share Posted June 9, 2008 what is the error exactly? Link to comment https://forums.phpfreaks.com/topic/109357-syntax-error/#findComment-560919 Share on other sites More sharing options...
BigX Posted June 9, 2008 Author Share Posted June 9, 2008 Okey, I will post the whole code: <?php $id = $_GET['id_usr']; $result = mysql_query("SELECT * FROM `poule a` WHERE user_id=" . $id); $query = mysql_query("SELECT * FROM ekpoule_users WHERE id_usr=" . $id); $naam = mysql_fetch_array($query); $color1 = "#009900"; $color2 = "#CC0000"; echo "<table width='450' border='0'>"; while($row = mysql_fetch_array($result)){ echo " <tr> <td width='250' align='left' style='font-size: 20px; color: #CC0000' bgcolor='#FFFFFF'><b>$naam[firstname_usr] $naam[lastname_usr]</b></td> <td width='100' align='left' style='font-size: 20px' bgcolor='#FFFFFF'><b> </b></td> <td width='100' align='left' style='font-size: 20px' bgcolor='#FFFFFF'><b> </b></td> </tr> <tr> <td width='250' align='left' style='font-size: 20px; color: #CC0000' bgcolor='#FFFFFF'><b> </b></td> <td width='100' align='left' style='font-size: 20px' bgcolor='#FFFFFF'><b> </b></td> <td width='100' align='left' style='font-size: 20px' bgcolor='#FFFFFF'><b> </b></td> </tr> <tr> <td width='250' align='left' style='font-size: 20px' bgcolor='#FFFFFF'><u><b>Poule A</b></u></td> <td width='100' align='left' style='font-size: 20px' bgcolor='#FFFFFF'><u><b>Uitslag</b></u></td> <td width='100' align='left' style='font-size: 20px' bgcolor='#FFFFFF'><u><b>Toto</b></u></td> </tr>"; $query2 = mysql_query("SELECT uitslag FROM echte_uitslagen WHERE id=1"); $uitslag = mysql_fetch_array($query2); if( $row['ZWI_TSJ_uitslag'] == $uitslag['uitslag'] ) { $kleur = $color1; } else { $kleur = $color2; } echo " <tr> <td width='250' align='left' style='font-size: 14px' bgcolor='#FFFFFF'><b>Zwitserland - Tsjechie</b></td> <td width='100' align='left' style='color: $kleur' style='font-size: 14px' bgcolor='#FFFFFF'><b>$row[ZWI_TSJ_uitslag]</b></td>"; $query2 = mysql_query("SELECT toto FROM echte_uitslagen WHERE id=1"); $uitslag = mysql_fetch_array($query2); if( $row['ZWI_TSJ_poule'] == $uitslag['toto'] ) { $kleur = $color1; } else { $kleur = $color2; } echo " <td width='100' align='left' style='color: $kleur' style='font-size: 14px' bgcolor='#FFFFFF'><b>$row[ZWI_TSJ_poule]</b></td> </tr>"; $query2 = mysql_query("SELECT uitslag FROM echte_uitslagen WHERE id=2"); $uitslag = mysql_fetch_array($query2); if( $row['POR_TUR_uitslag'] == $uitslag['uitslag'] ) { $kleur = $color1; } else { $kleur = $color2; } echo " <tr> <td width='250' align='left' style='font-size: 14px' bgcolor='#FFFFFF'><b>Portugal - Turkije</b></td> <td width='100' align='left' style='color: $kleur' style='font-size: 14px' bgcolor='#FFFFFF'><b>$row[POR_TUR_uitslag]</b></td>"; $query2 = mysql_query("SELECT toto FROM echte_uitslagen WHERE id=2"); $uitslag = mysql_fetch_array($query2); if( $row['POR_TUR_poule'] == $uitslag['toto'] ) { $kleur = $color1; } else { $kleur = $color2; } echo " <td width='100' align='left' style='color: $kleur' style='font-size: 14px' bgcolor='#FFFFFF'><b>$row[POR_TUR_poule]</b></td> </tr>"; $query2 = mysql_query("SELECT uitslag FROM echte_uitslagen WHERE id=3"); $uitslag = mysql_fetch_array($query2); if( $row['TSJ_POR_uitslag'] == $uitslag['uitslag'] ) { $kleur = $color1; } else { $kleur = $color2; } echo " <tr> <td width='250' align='left' style='font-size: 14px' bgcolor='#FFFFFF'><b>Tsjechie - Portugal</b></td> <td width='100' align='left' style='color: $kleur' style='font-size: 14px' bgcolor='#FFFFFF'><b>$row[TSJ_POR_uitslag]</b></td>"; $query2 = mysql_query("SELECT toto FROM echte_uitslagen WHERE id=3"); $uitslag = mysql_fetch_array($query2); if( $row['TSJ_POR_poule'] == $uitslag['toto'] ) { $kleur = $color1; } else { $kleur = $color2; } echo " <td width='100' align='left' style='color: $kleur' style='font-size: 14px' bgcolor='#FFFFFF'><b>$row[TSJ_POR_poule]</b></td> </tr>"; $query2 = mysql_query("SELECT uitslag FROM echte_uitslagen WHERE id=4"); $uitslag = mysql_fetch_array($query2); if( $row['ZWI_TUR_uitslag'] == $uitslag['uitslag'] ) { $kleur = $color1; } else { $kleur = $color2; } echo " <tr> <td width='250' align='left' style='font-size: 14px' bgcolor='#FFFFFF'><b>Zwitserland - Turkije</b></td> <td width='100' align='left' style='color: $kleur' style='font-size: 14px' bgcolor='#FFFFFF'><b>$row[ZWI_TUR_uitslag]</b></td>"; $query2 = mysql_query("SELECT toto FROM echte_uitslagen WHERE id=4"); $uitslag = mysql_fetch_array($query2); if( $row['ZWI_TUR_poule'] == $uitslag['toto'] ) { $kleur = $color1; } else { $kleur = $color2; } echo " <td width='100' align='left' style='color: $kleur' style='font-size: 14px' bgcolor='#FFFFFF'><b>$row[ZWI_TUR_poule]</b></td> </tr>"; $query2 = mysql_query("SELECT uitslag FROM echte_uitslagen WHERE id=5"); $uitslag = mysql_fetch_array($query2); if( $row['ZWI_POR_uitslag'] == $uitslag['uitslag'] ) { $kleur = $color1; } else { $kleur = $color2; } echo" <tr> <td width='250' align='left' style='font-size: 14px' bgcolor='#FFFFFF'><b>Zwitserland - Portugal</b></td> <td width='100' align='left' style='color: $kleur' style='font-size: 14px' bgcolor='#FFFFFF'><b>$row[ZWI_POR_uitslag]</b></td>"; $query2 = mysql_query("SELECT toto FROM echte_uitslagen WHERE id=5"); $uitslag = mysql_fetch_array($query2); if( $row['ZWI_POR_poule'] == $uitslag['toto'] ) { $kleur = $color1; } else { $kleur = $color2; } echo " <td width='100' align='left' style='color: $kleur' style='font-size: 14px' bgcolor='#FFFFFF'><b>$row[ZWI_POR_poule]</b></td> </tr>"; $query2 = mysql_query("SELECT uitslag FROM echte_uitslagen WHERE id=6"); $uitslag = mysql_fetch_array($query2); if( $row['TUR_TSJ_uitslag'] == $uitslag['uitslag'] ) { $kleur = $color1; } else { $kleur = $color2; } echo " <tr> <td width='250' align='left' style='font-size: 14px' bgcolor='#FFFFFF'><b>Turkije - Tsjechie</b></td> <td width='100' align='left' style='color: $kleur' style='font-size: 14px' bgcolor='#FFFFFF'><b>$row[TUR_TSJ_uitslag]</b></td>"; $query2 = mysql_query("SELECT toto FROM echte_uitslagen WHERE id=6"); $uitslag = mysql_fetch_array($query2); if( $row['TUR_TSJ_poule'] == $uitslag['toto'] ) { $kleur = $color1; } else { $kleur = $color2; } echo " <td width='100' align='left' style='color: $kleur' style='font-size: 14px' bgcolor='#FFFFFF'><b>$row[TUR_TSJ_poule]</b></td> </tr> <tr> <td width='250' align='left' style='font-size: 14px' bgcolor='#FFFFFF'><b> </b></td> <td width='100' align='left' style='color: #CC0000' style='font-size: 14px' bgcolor='#FFFFFF'><b> </b></td> <td width='100' align='left' style='color: #CC0000' style='font-size: 14px' bgcolor='#FFFFFF'><b> </b></td> </tr> <tr> <td width='250' align='left' style='font-size: 17px' bgcolor='#FFFFFF'><u><b>Eindstand Poule</b></u></td> <td width='100' align='left' style='color: #CC0000' style='font-size: 14px' bgcolor='#FFFFFF'><b> </b></td> <td width='100' align='left' style='color: #CC0000' style='font-size: 14px' bgcolor='#FFFFFF'><b> </b></td> </tr>"; echo $row['1e_poule_a']; echo " <tr> <td width='250' align='left' style='font-size: 14px' bgcolor='#FFFFFF'><b>$row[ZWI_TSJ_uitslag]</b></td> <td width='100' align='left' style='color: #CC0000' style='font-size: 14px' bgcolor='#FFFFFF'><b> </b></td> <td width='100' align='left' style='color: #CC0000' style='font-size: 14px' bgcolor='#FFFFFF'><b> </b></td> </tr> <tr> <td width='250' align='left' style='font-size: 14px' bgcolor='#FFFFFF'><b>$row[1e_poule_a]</b></td> <td width='100' align='left' style='color: #CC0000' style='font-size: 14px' bgcolor='#FFFFFF'><b> </b></td> <td width='100' align='left' style='color: #CC0000' style='font-size: 14px' bgcolor='#FFFFFF'><b> </b></td> </tr> <tr> <td width='250' align='left' style='font-size: 14px' bgcolor='#FFFFFF'><b>$row[ZWI_TSJ_uitslag]</b></td> <td width='100' align='left' style='color: #CC0000' style='font-size: 14px' bgcolor='#FFFFFF'><b> </b></td> <td width='100' align='left' style='color: #CC0000' style='font-size: 14px' bgcolor='#FFFFFF'><b> </b></td> </tr> <tr> <td width='250' align='left' style='font-size: 14px' bgcolor='#FFFFFF'><b>$row[ZWI_TSJ_uitslag]</b></td> <td width='100' align='left' style='color: #CC0000' style='font-size: 14px' bgcolor='#FFFFFF'><b> </b></td> <td width='100' align='left' style='color: #CC0000' style='font-size: 14px' bgcolor='#FFFFFF'><b> </b></td> </tr> "; } ?> The problem is in the lower part and the question is why does this array in the table work: <td width='250' align='left' style='font-size: 14px' bgcolor='#FFFFFF'><b>$row[ZWI_TSJ_uitslag]</b></td> And why won't this array in the table work when it's 'the same' in code: <td width='250' align='left' style='font-size: 14px' bgcolor='#FFFFFF'><b>$row[1e_poule_a]</b></td> I echo'd the $row[1e_poule_a] a little higher and that worked so there is noing wrong with the info in the table but it's an 'expected '[' error!! I hope you guys understand what I mean here Thanx for any help!! Link to comment https://forums.phpfreaks.com/topic/109357-syntax-error/#findComment-561073 Share on other sites More sharing options...
revraz Posted June 9, 2008 Share Posted June 9, 2008 Using CSS would really make your life easier. Link to comment https://forums.phpfreaks.com/topic/109357-syntax-error/#findComment-561124 Share on other sites More sharing options...
Lumio Posted June 9, 2008 Share Posted June 9, 2008 Using CSS would really make your life easier. Not only CSS... learning PHP for example or reading written posts. ZWI_TSJ_uitslag seams to be a constant and so it works. Link to comment https://forums.phpfreaks.com/topic/109357-syntax-error/#findComment-561346 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.