-2

Im messing around with some stuff for a school project and ran into a problem i failed to solve on my own, so here is my question.

Why do i get this error?

Parse error: syntax error, unexpected '$output2' (T_VARIABLE), expecting ',' or ';' in D:\Webserver\httpdocs\hosting-schultz.ch\test.hosting-schultz.ch\httpdocs\david.ettinger\search.php on line 29 

The site is hosted on http://test.hosting-schultz.ch/david.ettinger/search.php?suche=T3ST

At the moment, here is the relevant code:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta name="author" content="David Ettinger">
<meta name="editor" content="html-editor phase 5">
</head>
<body text="#000000" bgcolor="#FFFFFF" link="#FF0000" alink="#FF0000" vlink="#FF0000">
<?php

//creates img code for display of first and second img

$part1 = '<img src="';
$part2 = (string)$_GET["suche"];
$part3 = '.png" alt="404 image not found">';

// creates string for first image

$output1 = $part1.$part2.$part3;

echo $output;

// <br> to make both 404 readable

echo '<br>'

// creates string for second image

$output2 = $part1.$part2{1}.$part3;  <--- THIS IS LINE 29

echo $output2;

?>

</body>
</html>

I basically take the url parameter of suche, display the first image with the name suche.png. and i want to display a second image with the second char of suche e.g. "1234" -> I'm looking for 2 and i try to do that with part2{1}.

Everything worked fine until I tried adding the second image, hopefully you fine gentleman can make it work again..

Thanks very much in advance for your help!

Cheers

  • If a parse error is on line 29,... look at line 28, rule of thump – Daniel W. Jan 08 '14 at 19:26
  • I can't see how anything outputted before, as aside from the missing semi-colon after '
    ' - There are various other issues. 1. You should terminate your img tag by adding a / before you close the tag. Also, you're echoing out $output, but defining the variable as $output1. Technically, you should be seeing a broken image.
    – laminatefish Jan 08 '14 at 19:28
  • You are right, I fixed that shortly after the missing semicolon thing. – David Ettinger Jan 08 '14 at 21:54

2 Answers2

2
echo '<br>' // <-- missing semi-colon
John Conde
  • 217,595
  • 99
  • 455
  • 496
1

Missing a semi-colon after this line.

// <br> to make both 404 readable
echo '<br>'
sbeliv01
  • 11,550
  • 2
  • 23
  • 24