Solved

PHP Parse error: syntax error, unexpected '<' in /var/apache/lindamatthews.net/test/open.php on line 21

Posted on 2014-10-28
6
133 Views
Last Modified: 2014-10-28
I get this error
Parse error: syntax error, unexpected '<' in /var/apache/lindamatthews.net/test/open.php on line 21
from the code below.

I assume that line 21 is creating the prevPicture button (though I don't really know) but I don't see a problem in the code.  Anyone else have sharper eyes than me?

<?php
ini_set("display_errors", "On");
error_reporting(E_ALL);

include("header.php");
include("menu.php");
$info=urldecode($_GET["info"]);
$info=explode("%f ", $info);
$c=$_GET["c"];
$r=$_GET["r"];

$row=explode("%i ",$info[$r]);
 
echo "<div class=\"content\">";

echo "<table><tr><td>";
echo "<img id=pic src=".$row[0]." style=height:425px><td style=width:3%;>";
echo "<td>".$row[1];
echo "<tr><td>All images copyright Linda Matthews.";
echo "<td><button onclick=\"prevPicture()\"> Previous </button>";
echo      <button onclick=\"history.go(-1);\"> Thumbnails </button>";
echo      <button onclick=\"nextPicture()\"> Next </button>";
echo "</table></div>";

include("footer.php");


echo "<script type="text/javascript">";
echo "    function prevPicture() {";
echo "        document.getElementById(\"pic\").src=\"art/zen03.jpg\";";
echo "    }";
echo "   function nextPicture() {";
echo "        document.getElementById(\"pic\").src=\"art/zen04.jpg\";";
echo "    }";
echo "</script>";

Open in new window

0
Comment
Question by:padmasambhava
  • 2
  • 2
6 Comments
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 40407914
correct this line,
echo "        document.getElementById(\'pic\').src=\'art/zen03.jpg\';";

Open in new window


also this line,
echo "        document.getElementById(\'pic\').src=\'art/zen04.jpg\';";

Open in new window

0
 
LVL 11

Expert Comment

by:Radek Baranowski
ID: 40407916
change after line 20 to:

echo "<td><button onclick=\"prevPicture()\"> Previous </button>
          <button onclick=\"history.go(-1);\"> Thumbnails </button>
          <button onclick=\"nextPicture()\"> Next </button>";
0
 
LVL 36

Accepted Solution

by:
Loganathan Natarajan earned 500 total points
ID: 40407918
your entire code needs to be consistency on " and single quote
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 40408392
You can make this a lot easier if you learn about heredoc notation.

This kluge can be replaced...
echo "<div class=\"content\">";

echo "<table><tr><td>";
echo "<img id=pic src=".$row[0]." style=height:425px><td style=width:3%;>";
echo "<td>".$row[1];
echo "<tr><td>All images copyright Linda Matthews.";
echo "<td><button onclick=\"prevPicture()\"> Previous </button>";
echo      <button onclick=\"history.go(-1);\"> Thumbnails </button>";
echo      <button onclick=\"nextPicture()\"> Next </button>";
echo "</table></div>";

Open in new window


... by this, and you get free from all the fiddly punctuation and escape sequences.  You can line up the code, correct the markup, and get PHP variable substitution in HEREDOC.  It makes the programming much, much easier and far less error-prone! (I am not sure if this is the markup you want - I'm just trying to code it correctly for illustrative purposes.  Please treat this as untested code.)

$htm = <<<EOD
<div class="content">
<table>
  <tr>
    <td>
      <img id="pic" src="$row[0]" style="height:425px;" />
    </td>
    <td style="width:3%;">
    </td>
    <td>
      $row[1]
    </td>
  </tr>
  <tr>
    <td>
      All images copyright Linda Matthews
    </td>
    <td>
      <button onClick="prevPicture();"> Previous </button>
      <button onClick="history.go(-1);"> Thumbnails </button>
      <button onClick="nextPicture();"> Next </button>
    </td>
  </tr>
</table>
</div>
EOD;
echo $htm;

Open in new window


Sidebar note: You may also want to learn about the W3 validator.  The document at http://LindaMatthews.net cannot be validated because it starts with an HTML error!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
<html>
<head>

Open in new window

0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 40408448
This is kind of a different issue, but I noticed that one of the images in the site is 2995 x 1445 pixels - over 12 megabytes.  I have a lightning fast internet connection and it was slow even for my connection! Since it's being rendered as a 636 x 307 pixel element, it would make sense to create a separate copy of the original image and prepare it for use on the web.  This JPG version is only 21K, suggesting that it will load 590 times faster.
http://iconoun.com/demo/storage/art_img_0063.jpg

E-E has an Expert Testing "bugfinder" where you can submit a web site and the experts will look it over for things like this.  You might find it helpful.
http://www.experts-exchange.com/Expert_Testing/
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to create a scatter graph with straight lines 6 26
php ssh2_scp_send 1 47
PHP_POST() error message 9 41
How do I change the from header when sending a mail 1 16
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now