Jump to content

Find the error :))


BigX

Recommended Posts

Hi,

 

I have this piece of code and I get a Parse error: syntax error, unexpected '}' in line 173 which is the first if statement defining the header for the table! Probably a simple mistake...

 

<?php
if(isset($_GET['categorie'])) {  

$categorie = $_GET['categorie'];
if( $categorie == "1" ) {$header = "Algemene Juridische Hulp"};
if( $categorie == "2" ) {$header = "Consumenten"};
if( $categorie == "5" ) {$header = "Vreemdelingen"};
if( $categorie == "8" ) {$header = "Wonen en Huur"};

$organisaties_categorie = mysql_query("SELECT * FROM organisaties WHERE Categorie=" . $categorie." ORDER BY Organisatie ASC");

echo "<table width='350' cellspacing='0' border='0'>
<tr>
<th width='20' style='color: #CB0042' bgcolor='#FFFFFF'><div class='style11'><b>"$header"</b></div></th>
</tr>
<tr>
<th width='20' style='color: #CB0042' bgcolor='#FFFFFF'><div class='style11'><b> </b></div></th>
</tr>";
.....
?>

 

Any help is appreciated!

Link to comment
https://forums.phpfreaks.com/topic/98896-find-the-error/
Share on other sites

What he is trying to say is:

 

<?php
if( $categorie == "1" ) {$header = "Algemene Juridische Hulp"};
if( $categorie == "2" ) {$header = "Consumenten"};
if( $categorie == "5" ) {$header = "Vreemdelingen"};
if( $categorie == "8" ) {$header = "Wonen en Huur"};
?>

should be

<?php
if( $categorie == "1" ) {$header = "Algemene Juridische Hulp";}
if( $categorie == "2" ) {$header = "Consumenten";}
if( $categorie == "5" ) {$header = "Vreemdelingen";}
if( $categorie == "8" ) {$header = "Wonen en Huur";}
?>

 

The semicolon (;) should go after the action, not the curly bracket...

 

A good way to remember this is to write the code like this:

 

<?php
if( $categorie == "1" ){
   $header = "Algemene Juridische Hulp";
}elseif( $categorie == "2" ){
   $header = "Consumenten";
}elseif( $categorie == "5" ){
   $header = "Vreemdelingen";
}elseif( $categorie == "8" ){
   $header = "Wonen en Huur";
}
?>

 

Link to comment
https://forums.phpfreaks.com/topic/98896-find-the-error/#findComment-506027
Share on other sites

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.