I am having some trouble with a few lines of PHP code when I upload it to my domain over ftp. The lines below work on my local server on XAMPP but when I upload it to the remote server through my hosting client, instead of echoing out what it is supposed to, I get a blank page with no error log or message displayed. Any help would be greatly appreciated and thank you for taking the time to answer my question.
Code that doesn't work:
<?php
function getDominantColour($image, $type='png')
{
eval('$source = imagecreatefrom' . $type . '("' . $image . '");');
$source_x = imagesx($source);
$source_y = imagesy($source);
$resized_x = 100;
$resized_y = 100;
$resized= imagecreatetruecolor($resized_x, $resized_y);
imagecopyresampled($resized, $source, 0, 0, 0, 0, $resized_x, $resized_y, $source_x, $source_y);
$colours = array();
$rgb = '';
$index = array();
for ($x=0; $x<100; $x++)
{
for ($y=0; $y<100; $y++)
{
$rgb = imagecolorat($resized, $x, $y);
$index = imagecolorsforindex($resized, $rgb);
$key = 'R' . $index['red'] . 'G' . $index['green'] . 'B' . $index['blue'];
if (empty($colours[$key]))
{
$colours[$key] = 1;
} else {
$colours[$key]++;
}
}
}
arsort($colours, SORT_NUMERIC);
return key($colours);
}
echo(getDominantColour("http://maps.googleapis.com/maps/api/staticmap?center=40.727404,-74.020862&zoom=50&size=600x300&maptype=roadmap&markers=color:blue&sensor=false"));
?>