Return JSON array through PHP
Maybe it's better to return error in JSON (if FAIL constant isn't JSON yet)

echo json_encode(array('result' =&gt; false));


instead of

echo FAIL;


or return HTTP error code

header('HTTP/1.1 500 Internal Server Error');


And we can simplifify function get_data like this:

if(mysql_num_rows( $events_list )) // check if the query returned any records
{
    $mysql_record = mysql_fetch_array( $events_list );    // parse mysql result cursor
    return array(
        'e_id'                     =&gt; $mysql_record['eid'],
        'edisplay_date'            =&gt; $mysql_record['display_date'],
        'eword_of_the_day'         =&gt; $mysql_record['word_of_the_day'],
        'eword_of_the_day_meaning' =&gt; $mysql_record['word_of_the_day_meaning'],
        'ethought_of_the_day'      =&gt; $mysql_record['thought_of_the_day'],
        'ecrazyFact_of_the_day'    =&gt; $mysql_record['crazyFact_of_the_day'],
        'ejoke_of_the_day'         =&gt; $mysql_record['joke_of_the_day'],
    );
} else return false;