I am having problems getting a script to parse properly, and I can't for the life of me figure out what's wrong with it. The server is giving me a "PHP Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /var/www/cam.php on line.." which is the first "elseif" in this section:
if (isset($_REQUEST[‘cam’])) {
$cam = $_REQUEST[‘cam’];
} else {
$cam=1; // Default which camera should be displayed first
}
if ($cam==’1') {
$camurl=$camurl1;
$camtext=$camtext1;
} elseif ($cam==’2'){
$camurl=$camurl2;
$camtext=$camtext2;
} elseif ($cam==’3'){
$camurl=$camurl3;
$camtext=$camtext3;
} else {
$camurl=$camurl4;
$camtext=$camtext4;
}
I don't know if I simply spent too much time staring at the code already, or what, but I don't see any syntax error there. Complete script is as this (Trying to get some images, doing some work on them, and putting out xml for my phone to read). Anybody got an idea?
<?php
$camurl1="http://www.berlin.de/webcams/_img/webcam/alex.jpg";
$camtext1="Alex";
$buttontext1="Alex";
$camurl2="http://www.berlin.de/webcams/_img/webcam/alex.jpg";
$camtext2="Alex";
$buttontext2="Alex";
$camurl3="http://www.berlin.de/webcams/_img/webcam/alex.jpg";
$camtext3="Alex";
$buttontext3="Alex";
$camurl4="http://www.berlin.de/webcams/_img/webcam/alex.jpg";
$camtext4="Alex";
$buttontext4="Alex";
//the path to the imagefile. must be world-writable! chmod 777
$imagepath="/var/www/cam-image/image.png";
$imageurl="http://192.168.2.2/cam-image/image.png";
$camscripturl="192.168.2.2/cam.php";
////////////////////////////////////////////////////////////////////////
if (isset($_REQUEST[‘cam’])) {
$cam = $_REQUEST[‘cam’];
} else {
$cam=1; // Default which camera should be displayed first
}
if ($cam==’1') {
$camurl=$camurl1;
$camtext=$camtext1;
} elseif ($cam==’2'){
$camurl=$camurl2;
$camtext=$camtext2;
} elseif ($cam==’3'){
$camurl=$camurl3;
$camtext=$camtext3;
} else {
$camurl=$camurl4;
$camtext=$camtext4;
}
// Get the image from the camera
$image = file_get_contents($camurl);
// Create Imagick object
$im = new Imagick();
// Convert image into Imagick
$im->readimageblob($image);
// Resize image to match a cisco 7970 browser
$im->resizeImage(296,166,Imagick::FILTER_LANCZOS,1);
// Add a subtle border
$color=new ImagickPixel();
$color->setColor("rgb(220,220,220)");
$im->borderImage($color,1,1);
$im->setImageChannelDepth(imagick::CHANNEL_RED, 5);
$im->setImageChannelDepth(imagick::CHANNEL_GREEN, 12);
$im->setImageChannelDepth(imagick::CHANNEL_BLUE, 12);
$im->setImageFormat("png");
// Output the image
$output = $im->getimageblob();
$outputtype = $im->getFormat();
// output to file
$fp = fopen($imagepath, 'w');
fwrite($fp, $im);
fclose($fp);
$output= "
<CiscoIPPhoneImageFile>
<Prompt>" . $camtext . "</Prompt>
<URL>" . $imageurl . "</URL>
<SoftKeyItem>
<Name>" . $buttontext1 . "</Name>
<URL>" . $camscripturl . "?cam=1</URL>
<Position>1</Position>
</SoftKeyItem>
<SoftKeyItem>
<Name>" . $buttontext2 . "</Name>
<URL>" . $camscripturl . "?cam=2</URL>
<Position>2</Position>
</SoftKeyItem>
<SoftKeyItem>
<Name>" . $buttontext3 . "</Name>
<URL>" . $camscripturl . "?cam=3</URL>
<Position>3</Position>
</SoftKeyItem>
<SoftKeyItem>
<Name>" . $buttontext4 . "</Name>
<URL>" . $camscripturl . "?cam=4</URL>
<Position>4</Position>
</SoftKeyItem>
</CiscoIPPhoneImageFile>
";
header("Content-type: text/xml");
header("Connection: close");
header("Expires: -1");
echo $output;
?>