0

I am a complete beginner to PHP.

I can't find my mistake in the following code.

It says "syntax error, unexpected 'catch' (T_CATCH) in ... eval()'d code on line 185".

This " ?>" is line 185...

Is anyone able and willing to help me?

Thank you in advance,

Tim

I have nearly the same code for the tablet version of the website and there I don't have any errors.

<?php
    global $wpdb;
    global $startplz;
    global $zielplz;
    global $wertkategorie;
echo '<form class="kalkulator-phone" style="padding: 10px;" method="post" action="https://greendragon-webdesign.de/#kalkulator" >
<div style="background: #ae1704; padding: 20px 10px 0px 10px; box-shadow: inset 20px 0px 20px -10px #fff,inset -20px 0px 20px -10px #fff;">
<table>
<tbody>
<tr>
<td colspan="2" style=" text-align: center;"><img src="/wp-content/uploads/2021/12/New_Logo_Metalic_gold-2.png" />
<p style="color: #fff; font-weight: normal; line-height: 1.1; font-size: 21px;"><span style="font-weight: bold; font-size: 1.5em; margin-right: 5px;">PLZ</span> <span  style="font-size: 1.5em; ';
echo "font-family: 'Pinyon Script',handwriting!important; ";
echo 'font-weight: bold;">Kalkulator</span><br/>In <span style="font-size: 1.5em; font-weight: bold;">3</span> Schritten zum Frachtpreis</p>
<img width="60%" height="auto" src="/wp-content/uploads/2021/12/pricelist.png" />  
</td>  
</tr>
<tr>
<td colspan="2" style="vertical-align: middle; text-align: center;"><p style="color: #fff2cc;"><span style="font-size: 0.8em;">1. Schritt</span> <span style="font-family:';
echo " 'Pinyon Script',handwriting!important; ";
echo 'font-size: 1.5em;">Fahrzeug wählen...</span></p></td>
</tr>
<tr style="vertical-align: middle;">
<td style="width: 50%; text-align: center;"><img src="/wp-content/uploads/2021/12/PKW-Double-kalkulator.png" /></td>  
<td style="width: 50%; vertical-align: middle;">';
$wertkategorie = $_POST["kategorieList"];
if ($wertkategorie == 1){
  echo '<input type="radio" id="pkw" name="kategorieList" value="1" checked= "checked"> <label for="pkw">PKW</label>';
}
else {
  echo '<input type="radio" id="pkw" name="kategorieList" value="1"> <label for="pkw">PKW</label>';
}
echo '</td>  
</tr>
<tr style="vertical-align: middle;">
<td style="text-align: center;"><img src="/wp-content/uploads/2021/12/kombi-caddy-kalkulator.png" /></td>  
<td style="vertical-align: middle;">';
if ($wertkategorie == 2){
  echo '<input type="radio" id="kombi" name="kategorieList" value="2" checked= "checked"> <label for="kombi">KOMBI</label>';
}
else {
  echo '<input type="radio" id="kombi" name="kategorieList" value="2"> <label for="kombi">KOMBI</label>}';
echo '</td> 
</tr>
<tr style="vertical-align: middle;">
<td style="text-align: center; padding-top: 15px; padding-bottom: 20px;"><img src="/wp-content/uploads/2021/12/transp-A-kalkulator.png" /></td>  
<td style="vertical-align: middle;">';
if ($wertkategorie == 3){
  echo '<input type="radio" id="transp1" name="kategorieList" value="3" checked= "checked"> <label for="transp1">BUS</label>';
}
else {
  echo '<input type="radio" id="transp1" name="kategorieList" value="3"> <label for="transp1">BUS</label>';
}
echo '</td> 
</tr>
<tr style="vertical-align: middle;">
<td tyle="text-align: center;"><img src="/wp-content/uploads/2021/12/Transp-B-kalkulator.png" /></td>  
<td style="vertical-align: middle;">';
if ($wertkategorie == 4){
  echo '<input type="radio" id="transp2" name="kategorieList" value="4" checked= "checked"> <label for="transp2">MAXI Transporter</label>';
}
else {
  echo '<input type="radio" id="transp2" name="kategorieList" value="4"> <label for="transp2">MAXI Transporter</label>';
}
echo '</td>
</tr>
<tr>
<td colspan="2" style="vertical-align: middle; text-align: center;"><p style="color: #fff2cc;"><span style="font-size: 0.8em;">2. Schritt</span> <span style="font-family:';
echo " 'Pinyon Script'";
echo ',handwriting!important; font-size: 1.4em;">Start</span> <span style="font-size: 1.4em; font-weight: bold;">PLZ</span></p></td>
</tr>
<tr>
<td colspan="2" style="text-align: center;  padding-bottom: 3px;">';
$result1 = $wpdb->get_results ( "SELECT distinct (zip1) FROM versuch1" );
$startplz = $_POST["zip1List"];
echo '<select name="zip1List" id="zip1">
  <option selected="selected">';
  if ($startplz > 0) {
    echo $startplz;
  }
  else {
    echo '00000';
  }
  echo '</option>';

  foreach( $result1 as $value1 ) { 
 echo '<option value="';

 echo $value1->zip1; 

 echo '">';

 echo $value1->zip1; 
 echo '</option>';
 
};
echo '</select></td> 
</tr>
<tr>
<td colspan="2" style="vertical-align: middle; text-align: center;"><p style="color: #fff2cc; padding-top: 10px;"><span style="font-size: 0.8em;">3. Schritt</span> <span style="font-family: ';
echo "'Pinyon Script'";
echo ',handwriting!important; font-size: 1.4em;">Ziel</span> <span style="font-size: 1.4em; font-weight: bold;">PLZ</span></p></td>
</tr>
<tr>
<td colspan="2" style="text-align: center; padding-top: 3px; padding-bottom: 15px;">';
$result2 = $wpdb->get_results ( "SELECT distinct (zip2) FROM versuch1" );
$zielplz = $_POST["zip2List"];
echo '
<select style="margin-bottom: 10px;" name="zip2List" id="zip2">
  <option selected="selected">';
  if ($zielplz > 0) {
    echo $zielplz;
  }
  else {
    echo '00000';
  }
  echo '</option>';

  foreach( $result2 as $value2 ) { 
 echo '<option value="';

 echo $value2->zip2; 

 echo '">';

 echo $value2->zip2; 
 echo '</option>';
 
};
echo '</select>
<p>
<input class="et_pb_button et_pb_custom_button_icon" data-icon="E" type="submit" name="submit" value="Berechnen" >
</p>
</td>
</tr>
<tr>
<td colspan="2" style="vertical-align: middle; text-align: center;"><p style="color: #fff2cc; line-height: 1.4;"><span style="font-family: ';
echo "'Pinyon Script'";
echo ',handwriting!important; font-size: 1.3em;">Ihr</span> <span style="font-size: 1.2em; font-weight: bold;">Frachtpreis</span></p></td>
</tr>
<tr>
<td class="result" colspan="2" style="text-align: center; vertical-align: middle; height: 45px!important;">';
if(isset($_POST['submit'])) {
  if (isset($_POST['kategorieList'])) {
    if (isset($_POST['zip1List'])) {
        if (isset($_POST['zip2List'])) {
          $kategorie = $_POST['kategorieList'];
          $zip1 = $_POST["zip1List"];
          $zip2 = $_POST["zip2List"];
          $resultsap = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM versuch1 WHERE zip1 = %s AND zip2 = %s", $zip1, $zip2 ) );
          foreach ($resultsap as $row) {
            switch ($kategorie) {
              case 1:
        echo "€ $row->cost1";
        break;
    case 2:
        echo "€ $row->cost2";
        break;
    case 3:
        echo "€ $row->cost3";
        break;
    case 4:
        echo "€ $row->cost4";
        break;
            }
          }
        }
      }
    }
  }
echo '</td>  
</tr>
<tr>
<td style="vertical-align: middle;"><p style="color: #fff2cc; line-height: 1.2; margin-right: -10%; padding-bottom: 0px;"><span style="font-size: 0.7em; color: #fff;">Frachtpreis kann aufgrund von Serviceleistungen (SZ/WZ) abweichen</span></p></td>
<td style="padding-left: 15px; vertical-align: bottom; text-align: right;"><span style="font-size: 0.7em; color: #fff;">zzgl. MwSt.</span><img style="margin-top: 10px;" src="/wp-content/uploads/2021/12/Bester_preis_in_town.png" width="50" height="auto" /></td>  
</tr>
<tr>
<td colspan="2" style="padding: 0!important;"><div style="background: #fff !important; margin-left: -20px!important; margin-right: -20px!important; padding-top: 5px!important;"><p style="font-size: 11px; font-weight: bold; color: #000; text-align: center; line-height: 1.3; padding-bottom: 5px!important; padding-left: 10px; padding-right: 10px;">Die PLZ 022113 <span style="font-size: 9px;">(Oststeinbek)</span> bzw. PLZ 022145 <span style="font-size: 9px;">(Stapelfeld/Braak)</span> für Bezirke außerhalb Hamburg!</p>
<p style="font-size: 0.5em; color: #000; text-align: center; line-height: 1.3; margin-right: 10px; margin-left: 10px;">Ein Produkt der City-Schnellbote GmbH / Stand 12.2021 / Irrtümer vorbehalten / Gerichtsstand Hamburg / Es gelten unsere AGB</p></div></td>
</tr>  
</tbody> 
</table>
</div>
</form>';
?>
  • 1
    This code contains neither catch nor eval. Are you sure this is the right file. Which is line 185? The last one? Clearly that line doesn't contain anything it's complaining about – ADyson Jan 09 '22 at 12:38
  • 2
    Very hard to read code but you didn't close something. Use proper indentation. – user3783243 Jan 09 '22 at 12:38

0 Answers0