Jump to content

Texan78

Members
  • Posts

    272
  • Joined

  • Last visited

Community Answers

  1. Texan78's post in PHP Fatal error: Call to a member function query() on a non-object was marked as the answer   
    They are EXACTLY the same line numbers. I copy and pasted them into a notepad to save for later then commented out the DB connection to stop it from making connections. 
     
    This.... 
    /* Lets connect to the database */ //include('dbconn.php'); Has zero to do with the error as I still get the SAME error regardless if it is commented out or not. So ignore it even exists. Had I not posted that part at all then I am sure I would be getting completely different responses. 
     
    No worries, thanks for the help. Its apparent no one is looking BEYOND what I am saying and only focusing on that being commented out instead of listening to what I am saying that it doesn't matter. I get the same error regardless even with waiting a couple hours which is plenty of time for the varnish cache to clear. 
  2. Texan78's post in Make HTTP GET request with cURL from Wowza Rest API was marked as the answer   
    Here is the final result. Thanks to everyone who contributed their time and skills in helping me with this in my learning process. Now on to trying to take these variables to update the DB. If there is no further objections or suggestions here is the final code. 
    $headers[] = 'Connection: Keep-Alive'; $headers[] = 'Content-Type: application/json;charset=utf-8'; $headers[] = 'Accept: application/json'; $userAgent = 'php'; $url = 'http://domain.com:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/instances/_definst_/incomingstreams/ncopeland'; $cURL = curl_init(); curl_setopt($cURL, CURLOPT_URL, $url); curl_setopt($cURL, CURLOPT_HTTPHEADER, $headers); curl_setopt($cURL, CURLOPT_USERAGENT, $useragent); curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true); curl_setopt($cURL, CURLOPT_HTTPGET, true); $result = curl_exec($cURL); curl_close($cURL); // Lets get and parse the data and create the variables $obj = json_decode($result); $chaser = $obj->name; $streamStatus = $obj->isConnected?'true':'false';
  3. Texan78's post in Looping through JSON file to find value was marked as the answer   
    Thanks, I have already resolved this and it is working like I am wanting it to. It may not be perfect but it does what I need it to. Your solution really doesn't make much sense to me. Not saying it is wrong, just saying I didn't understand what you were doing or where to apply it. This is what I have come up with and it's working fine now in all aspects. 
    $resultArr = array();//to store results //lets execute the query $executingFetchQuery = $mysqli->query("SELECT `StreamStatus` FROM streamdb WHERE 1"); if($executingFetchQuery) { while($arr = $executingFetchQuery->fetch_assoc()) { $resultArr[] = $arr['StreamStatus'];//storing values into an array } } $counts = array_count_values($resultArr);//lets count the results $online = $counts['true']; // Lets assemble the banners to display $notifyOffline = '<div class="alert alert-danger" role="alert" data-toggle="tooltip" data-placement="top" title=" "> There are currently no active chasers online streaming at this time.</div>'; $notify1Online = '<div class="alert alert-success" role="alert" data-toggle="tooltip" data-placement="top" title=" "> There is currently 1 chaser streaming LIVE... </div>'; $notifyOnline = '<div class="alert alert-success" role="alert" data-toggle="tooltip" data-placement="top" title=" "> There are currently '.$online.' chasers streaming LIVE... </div>'; //lets display the banners if ( $online == "1" ) { echo $notify1Online; } elseif ( $online >= "2" ) { echo $notifyOnline; } else { echo $notifyOffline; }
  4. Texan78's post in If array total is equal to echo message if greater display different message was marked as the answer   
    Got this resolved. Helps if I was using the right variable to get the correct value. Was using $total when I should have been using $online which is why the == wasn't working when I first tried it as it was suppose to be. 
    //lets display the banners if ( $online == "1" ) { echo $notify1Online; } elseif ( $online >= "2" ) { echo $notifyOnline; } else { echo $notifyOffline; }
  5. Texan78's post in Generate JSON with PHP from MySQL DB? was marked as the answer   
    I got it sorted with this solution and seems to work great and is lightweight. 
    <?php $pdo = new PDO('mysql:dbname=_streamdb;host=localhost;','root','password', [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ]); $result = $pdo->query('SELECT DisplayName, StreamKey, StreamURL, gpsStatus, UserLat, UserLon, UserHeading, UserLocation, UserLocation, streamStatus, CurrentViewers, TimeStamp FROM maintable'); $rows = $result->fetchAll(PDO::FETCH_ASSOC); header('Content-Type: application/json;charset=utf-8'); echo json_encode(['streamers' => $rows], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK); ?>
  6. Texan78's post in Problem with include statement was marked as the answer   
    I got it sorted out by using this below. I am not sure if this is the correct method but, it works. I think because it is an addon domain and the files are in a sub-domain of the add on domain the normal method doesn't work as normal I am assuming. 
    <?php include($_SERVER['DOCUMENT_ROOT'].'/network/kdfw/inc/chaserData.php'); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.