Isaac_4 39 Junior Poster in Training

You may have done this but often I find a reboot or two resolves this type of issue for me. Open up Settings > Windows Update and click Check for updates, wait for it to finish, then reboot. Do this twice and it is likely to clear up, otherwise it may just be something that takes longer to download. If it does go on for longer then you may have a more serious issue indeed.

Isaac_4 39 Junior Poster in Training

If there is an existing AC connection between the two buildings you may be able to get by with an ethernet over powerline adapter such as http://www.amazon.com/TP-LINK-TL-PA4010KIT-Powerline-Adapter-Starter/dp/B00AWRUICG/ref=sr_1_3?ie=UTF8&qid=1457965921&sr=8-3&keywords=ethernet+over+power

Isaac_4 39 Junior Poster in Training

If I am guessing correctly, you are just trying to get some basics to work before you implement the actual functionality. There's nothing wrong with that!

The problem basically is just that you need to declare the $title variable as global in each of the functions that references it. I would do away with the set_title function completely and change get_header:

<?php
function get_header(){
    global $title;
    include 'header.php';
}
function get_footer(){
    include 'footer.php';
}

Then in header.php:

<!DOCTYPE html>
<html>
<head>
    <title><?php echo $title; ?></title>
    <meta charset="UTF-8">
    <meta name="description" content="Photography site" />
    <meta name="keywords" content=" Angelic Photography" />
<!--    <link rel="stylesheet" href="assets/css/main.css"/>-->
    <link rel="stylesheet" href="assets/css/bootstrap.min.css"/>
     <link rel="stylesheet" href="assets/css/grayscale.css"/>
</head>

The key thing to remember is that when you include() or require() a file, the code in it is processed exactly as if you had pasted in that code in the same position as the include() call in the parent file. In this case, that means that in order to access the $title variable you either have to use a global or pass it in as an argument.

A better approach
You may want to consider not relying on globals at all, however, in which case you would want to pass the page data to the get_header() and get_footer() functions like this:

<?php
/**
 * Render the header markup for a basic page.
 * @param $page array of data for the page.
 * @return nothing
 */
function get_header($page) {
    include 'header.php';
}

/**
 * Render the footer markup …
Isaac_4 39 Junior Poster in Training

Cache in the PHP level is not going to help in this case. The person at your hosting company was probably either talking about browser caching, or didn't really have a good answer to give you.

Allowing the users to upload the files is fine, but you need to resize them before you include them on a page. PHP has a bunch of built in functions in the GD and ImageMagick libraries that can do this. If you can't quite figure it out, I can write a function for you later tonight or torrow and show how I do it.

For the YouTube video ID you probably want to use explode() or preg_match() depending on how fancy you want to get.

SimonIoa commented: Thanks Isaac +2
Isaac_4 39 Junior Poster in Training

Yeah, as I suspected this isn't to do with your PHP code at all. Your PHP file replies in about 200 milliseconds, then the browser spends all it's time downloading the many assets needed to render the page.

You would need to take an alternative approach to the front-end of this page in order to improve it's performance. There are two things that I would suggest trying first:

# 1. One big problem is this JPG file, amongst others on the page: http://www.rovespier.com/user_profile_uploads/141979704492.jpg

This file is 1.1MB, which is massive for a web page. You never want to allow users to upload files of an unlimited size without resizing them. If you resized this file on upload to make it the size that you want it at (looks like it is used at a resolution of 102x102 pixels) the results would load much faster.

# 2. For the YouTube videos I suggest embedding a thumbnail for the video as a link, rather than the video itself. This will cause the page to load much faster as well.

You can generate thumbnails by loading these files, replacing [video-id] with the ID for the video:

http://img.youtube.com/vi/[video-id]/0.jpg
http://img.youtube.com/vi/[video-id]/1.jpg
http://img.youtube.com/vi/[video-id]/2.jpg
http://img.youtube.com/vi/[video-id]/3.jpg

More infor on thumbnails in the first answer to this question on SO.

Isaac_4 39 Junior Poster in Training

What is the URL to your page? The ISP's notes sound more related to a frontend (i.e. your browser can't load that many videos at once) than something you could solve in PHP, but it would be impossible for us to know without looking at the page as it loads.

Isaac_4 39 Junior Poster in Training

Well it's actully returning some data. The three ... in bold mean that the output is being truncated because it's too deep. Try using print_r() instead of var_dump():

echo '<pre>';
print_r($obj);
echo '</pre>';

That should show you all the nested objects and arrays. You have to dig deeper into the returned data.

You probably have to do something like

foreach($obj->monitors->monitor as $monitor) {
    var_dump($monitor);
}
Isaac_4 39 Junior Poster in Training

Well without a valid API key the call returns an error object which does not have a datetime property.

Obviously you don't want to post your API key but can you post what object you do get from the last var_dump? It needs to actually have a datetime property or you will get an error (if errors are enabled) and $cc will remain unset.

Isaac_4 39 Junior Poster in Training

Some sample code. Post data to your customer's PHP file like this:

// Read data from DB
$query = $db->execute("SELECT * FROM `dlr_tbl` WHERE `fetched` = '0'");
$row = $query->getrows();

// Create an array of rows to encode, using the field names we want
$array_data = array();
for($i=0;$i<count($row);$i++) {
    $post_data[] = array(
        'extid' => $row[$i]['external_id'],
        'status' => $row[$i]['delivery_status'],
        'cause' => $row[$i]['cause'],
        'mobile' => $row[$i]['mobile_no'],
        'date' => $row[$i]['delivery_date'],
    );
}

// Encode data to a JSON packet
$json_data = json_encode($array_data);

echo 'DEBUG SEND: '.$json_data.'<hr/>'; // DEBUG only

// Post the JSON packet - no GET parameters needed, everything is
// in $json_data already
$furl = "http://www.example.com/library/getresponse.php";
$ch = curl_init($furl);
curl_setopt_array($ch, array(
    CURLOPT_URL => $furl,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => $json_data
));
$curl_scraped_page = curl_exec($ch);
echo 'DEBUG RESULT: '.$curl_scraped_page; // DEBUG only
curl_close($ch);

Then in your customer's PHP file, getresponse.php, you can get the array back out like this:

// php://input returns all POST data. We want to decode it as JSON
$post_data = file_get_contents("php://input");
if($post_data) {
    if(substr($post_data, 1, 1) != '{') || substr($post_data, -1, 1) != '{')) exit('Error, POST data does not look like JSON');

    echo 'DEBUG RECV: '.$post_data.'<hr/>'; // DEBUG only
    $array_data = json_decode($post_data);
    var_dump($array_data); // DEBUG only
} else exit('Error, no data in POST!');
Isaac_4 39 Junior Poster in Training

Also all the data in the CURLOPT_POSTFIELDS will not be in the URL but rather part of the POST body, so don't worry about problems with URL length. gabrielcastillo's suggestion is a good way to do this.

Isaac_4 39 Junior Poster in Training

The problem is that the return result is not a valid JSON string:

jsonUptimeRobotApi({"stat": "fail","id":"100","message":"apiKey not mentioned or in a wrong format"})

This is, rather, a JavaScript function call. This type of "JSON" return is meant for consumption on the front-end of a website, inside the browser.

The easiest fix is probably to just parse out the JS function call with some string functions:

$api_key = "apikey here";
$server = "http://api.uptimerobot.com/getMonitors?apiKey=" . $api_key . "&logs=1&alertContacts=1&responseTimes=1&responseTimesAverage=180&format=json";
$server2 = file_get_contents($server);

if(substr($server2, 0, 19) == 'jsonUptimeRobotApi(' && substr($server2, -1, 1) == ')')
{
    $json = substr($server2, 19, strlen($server2) - 20);
    if(!is_null($json)) {
        $obj = json_decode($json);
        var_dump($obj);

        $cc =  $obj->datetime;// I assume that $alert was meant to be $obj
        echo $cc;
    }
}