Jump to content

Texan78

Members
  • Posts

    272
  • Joined

  • Last visited

Everything posted by Texan78

  1. Thank you for the detailed information. It is very helpful and I will keep it into memory. A lot of it was trial and error from reading php.net and numerous other sites trying to self teach myself. I do like cleaner and simpler methods which is why I am trying to clean this up. What I am a little puzzled with is the code you posted. How do I know what the variables are so I can use the data in the rest of my code?
  2. Quick update, I have been doing more research and reading the manual and I think I have found a solution. It works and while that is great I am not sure if it is correct and current. It is certainly more stream line. Does anyone have any suggestions on a better way or if this is correct? $sql = "SELECT gpsStatus, DisplayName, ChaserLocation, StreamStatus, CurrentViewers, TimeStamp FROM streamdb WHERE id = 1"; $result = $mysqli->query($sql); $row=mysqli_fetch_array($result,MYSQLI_ASSOC); printf ("\n",$gpsStatus = $row["gpsStatus"],$DisplayName = $row["DisplayName"],$chaserLocation = $row["ChaserLocation"],$status = $row["StreamStatus"],$totalViewers = $row["CurrentViewers"],$timeStamp = $row["TimeStamp"]); if (!$result) { echo "Error executing query: (" . $mysqli->errno . ") " . $mysqli->error; } /* close connection */ $mysqli->close(); -Thanks!
  3. Hello, I am trying to update and clean up some MySQL queries I have to condense them into a single query and return variables from the result of each field. A lot has changed since I last used this so I am trying to learn the new methods. While this works, it is impractical and not current. So I am trying to condense this into a single query as this is currently how I am query it to create variables from the fields for a certain row. For brevity I have only include a few examples. $sql = "SELECT gpsStatus FROM streamdb WHERE id = 1"; $result = $mysqli->query($sql); if ($result->num_rows > 0) { // output data of each row $i = 1; while($row = $result->fetch_assoc()) { $gpsStatus[$i] = $row["gpsStatus"]; $i++; } } $sql = "SELECT DisplayName FROM streamdb"; $result = $mysqli->query($sql); if ($result->num_rows > 0) { // output data of each row $i = 1; while($row = $result->fetch_assoc()) { $DisplayName[$i] = $row["DisplayName"]; $i++; } } $sql = "SELECT ChaserLocation FROM streamdb"; $result = $mysqli->query($sql); if ($result->num_rows > 0) { // output data of each row $i = 1; while($row = $result->fetch_assoc()) { $chaserLocation[$i] = $row["ChaserLocation"]; $i++; } } Now I am trying to take the above and combine it into a single query to return multiple variables from the fields of a single row but, I am having a little trouble as I can't seem to find what I am looking for in the php manual and all the examples I have tinkered with hasn't worked. So how do I need go about taking the code above and condensing it into a single query like I am trying to do below and create multiple variables? /* Lets make a connection to the database and check for connection errors */ include('dbconn.php'); /* Lets query the database and return the current values */ $sql = "SELECT gpsStatus, DisplayName, ChaserLocation, StreamStatus, CurrentViewers, TimeStamp FROM streamdb WHERE id = 1"; $result = $mysqli->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) $gpsStatus = $row["gpsStatus"]; $DisplayName = $row["DisplayName"]; $chaserLocation = $row["ChaserLocation"]; $status = $row["StreamStatus"]; $totalViewers = $row["CurrentViewers"]; $timeStamp = $row["TimeStamp"]; } if (!$sql) { echo "Error executing query: (" . $mysqli->errno . ") " . $mysqli->error; } /* close connection */ $mysqli->close(); echo $DisplayName; In case anyone is curious what the dbconn.php contains it is as follows and it connects fine as I put in a statement to echo on successful connection while I am testing. For privacy I didn't include the actual variable values naturally. /* Connect to database */ $mysqli = new mysqli($servername, $username, $password, $dbname); //check connection if($mysqli->connect_errno>0) { die("Connection to MySQL-server failed!" . $conn->connect_error); } else { echo "Connection Successful"; } -Thanks!
  4. 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';
  5. Thanks! That works! I forgot all about that. Forgot when it returns values nothing is false and 1 is true and that had to be added. You left off the ' after false but I caught it. Just a question though for future reference. Why isn't true/false value returned when its parsed when its in the original string when you call it in a browser but not in the script? -Thanks
  6. I understand but I don't follow what you're referring to in relation to my current issue at the moment with the true/false values not being displayed. $cURL is the variable and I don't see any that are all lower case. I've already addressed and corrected that a couple of posts back.
  7. Ok I am getting closer. I have the response as objects now but, I am not getting the true false values. I think that is the last thing I need to sort out. http://stream.dfwstormforce.com/inc/chasers/test.php $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); echo('<pre>'.print_r($obj,1).'</pre>'); echo $obj->name; echo $obj->isConnected; -Thanks
  8. I sorted out the error but now I don't get anything. This.... curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); Should be curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true); The $cURL was all lower case which was throwing the error. So that part is resolved but still not getting any output.
  9. Yes, I am getting the "make sure I am viewing the correct script" so I am viewing the correct one. You can see that here... http://stream.dfwstormforce.com/inc/chasers/test.php Which is using this code minus the including the URL variable for brevity. $cURL = curl_init(); curl_setopt($cURL, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); //curl_setopt($cURL, CURLOPT_HTTPGET, true); curl_setopt($cURL, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json;charset=utf-8', 'Accept: application/json' )); echo('make sure I am viewing the correct script'); $result = curl_exec($cURL); var_dump($result); exit; I did run the full code in the playground and it is giving me this error. "Warning: curl_setopt() expects parameter 1 to be resource, null given in - on line 8" which is at least something positive to give some direction. https://www.tehplayground.com/myslcPbSqzzI3KvX -Thanks!
  10. Still getting the same output. I will leave it be and you can check that link I posted earlier. Something is wacky with it just not sure what. $cURL = curl_init(); curl_setopt($cURL, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($cURL, CURLOPT_HTTPGET, true); curl_setopt($cURL, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json;charset=utf-8', 'Accept: application/json' )); echo('make sure I am viewing the correct script'); $result = curl_exec($cURL); var_dump($result); exit; // Lets get and parse the data and create the variables /* $obj = json_decode($result); echo('<pre>'.print_r($obj,1).'</pre>'); echo $obj->name; echo $obj->isConnected; */ I even tried it with adding this to see if I would get any errors and still the same output and no errors. $result = curl_exec($cURL); // Check for errors and display the error message if($errno = curl_errno($cURL)) { $error_message = curl_strerror($cURL); echo "cURL error ({$errno}):\n {$error_message}"; } curl_close($cURL); I am scratching my head. I know I don't know much about cURL but I think I am understanding it right, it's just not getting formatted correctly on the output and not sure why. Could be be something with my CURLOPT? -Thanks!
  11. You're absolutely right and I agree. When I inserted the string direct into a varible like that I comes out correctly. When I pull it from the this string.. $result = curl_exec($cURL); curl_close($cURL); // Lets get and parse the data and create the variables $obj = json_decode($result); Then I get a different output. So I am not sure if my cURL OPTS are set correctly or if $result = curl_exec($cURL); is causing some issues. When a do a var dump on $cURL though it returns NULL if that helps or means anything.
  12. If I understand correctly according to this http://php.net/json_decode the JSON response I am getting isn't proper formatted json. {"serverName":"_defaultServer_","sourceIp":"ncopeland","isPTZEnabled":false,"applicationInstance":"_definst_","name":"ncopeland","isRecordingSet":false,"isStreamManagerStream":true,"isPublishedToVOD":false,"isConnected":false,"ptzPollingInterval":2000} According to the manual it should be like this if I understand it correctly. {"serverName":_defaultServer_ "sourceIp":ncopeland "isPTZEnabled":false } The value isn't suppose to be wrapped in single or double quotes and trailing commas are not allowed if I understand that correctly or maybe that is just when it is used in the code?
  13. I think I took the CURLOPT_RETURNTRANSFER out by accident trying different things since I am still learning cURL and what the different options do experimenting so I know what they do so I know in the future. I have added it back but, I am still getting the same output. I even cleared my browser cache and restarted my computer since I did just get a dedicated IP last night just in case that is playing into it. This is currently what I have right now. $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_RETURNTRANSFER, true); curl_setopt($cURL, CURLOPT_HTTPGET, true); curl_setopt($cURL, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json;charset=utf-8', 'Accept: application/json' )); $result = curl_exec($cURL); curl_close($cURL); // Lets get and parse the data and create the variables $obj = json_decode($result); echo('<pre>'.print_r($obj,1).'</pre>'); echo $obj->name; echo $obj->isConnected; And this is what I am getting in return. http://stream.dfwstormforce.com/inc/chasers/test.php I don't need the entire response just the two values. I am only going to use the name to compare it to the name field in the DB so I can insert the isConnected value to the right user. I may not even go that route at all. May just insert the variable from the response directly into the code and if I go that route I just need the one value but, I have to do that for 6 other files too so thought it may be easier to call them all globally from a single file and update and insert them into the DB all at once since the variable is already connected to the DB I am using on the final page and I know it works because I can change the true/false in the database manually and it updates the icon which it is controlling via jQuery. Just trying to get this API response connect to it one way so that it is fully dynamic and will update when the status changes. -Thanks
  14. Thanks for the input. It doesn't have to be an array, I would rather keep it as an object. I just figured if it was in an array it would be easier to work with when it came to inserting the value into the DB. I would rather keep it as an object but wasn't sure how to work with it as an object. Something isn't right though. I don't know if it has to do with just getting a dedicated IP and propagation isn't fully completed or what but, the code isn't parsing correctly. It's ether that or there is something I am missing in my code. This is currently what I have and I have tried many different combinations and tried many numerous things to even list. Did var_dump and it's not returning correctly. The original response is in XML and formatted like so. <IncomingStream serverName="_defaultServer_"> <ApplicationInstance>_definst_</ApplicationInstance> <Name>ncopeland</Name> <SourceIp>ncopeland</SourceIp> <IsRecordingSet>false</IsRecordingSet> <IsStreamManagerStream>true</IsStreamManagerStream> <IsPublishedToVOD>false</IsPublishedToVOD> <IsConnected>false</IsConnected> <IsPTZEnabled>false</IsPTZEnabled> <PtzPollingInterval>2000</PtzPollingInterval> </IncomingStream> This is my current code. $url = 'http://domain_name: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_HTTPGET, true); curl_setopt($cURL, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json;charset=utf-8', 'Accept: application/json' )); $result = curl_exec($cURL); curl_close($cURL); // Lets get and parse the data and create the variables $obj = json_decode($result); echo('<pre>'.print_r($obj,1).'</pre>'); echo $obj->name; echo $obj->isConnected; This is the output I get from the above. {"serverName":"_defaultServer_","sourceIp":"ncopeland","isPTZEnabled":false,"applicationInstance":"_definst_","name":"ncopeland","isRecordingSet":false,"isStreamManagerStream":true,"isPublishedToVOD":false,"isConnected":false,"ptzPollingInterval":2000}1 It's like it's not doing anything. Maybe it has something to do with the <IncomingStream serverName="_defaultServer_"> and I am just not doing something right. Not sure where to start to begin troubleshooting. -Thanks
  15. Yes I was and I was thinking the same as you and did some research and it turned out that it was a firewall issue on my web hosts side. Apparently Bluehost blocks all ports but the important ones unless you have a Dedicated IP. So I got a dedicated IP and now I am able to make the requests but still having a small issue trying to get what I am needing. I am able to make the request and return a response but, it isn't formatting like I am needing it. The URL actually returns it in XML but Wowza support says it I can get the response in JSON by adding the content type as I have done. $url = 'http://DOMAINNAME: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_HTTPGET, true); curl_setopt($cURL, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json;charset=utf-8', 'Accept: application/json' )); $result = curl_exec($cURL); curl_close($cURL); $obj = json_decode($result); echo $obj->name; echo $obj->isConnected; The response should be this. { "serverName": "_defaultServer_", "sourceIp": "ncopeland", "isPTZEnabled": false, "applicationInstance": "_definst_", "name": "ncopeland", "isRecordingSet": false, "isStreamManagerStream": true, "isPublishedToVOD": false, "isConnected": true, "ptzPollingInterval": 2000 } But, instead the response is being returned and formatted like this. {"serverName":"_defaultServer_","sourceIp":"ncopeland","isPTZEnabled":false,"applicationInstance":"_definst_","name":"ncopeland","isRecordingSet":false,"isStreamManagerStream":true,"isPublishedToVOD":false,"isConnected":false,"ptzPollingInterval":2000} How can I format this so I can get these into usable variables. Really all I am needing from the response is "name" and "isConnected" so I can updated fields in a DB like this. Array ( [serverName] => _defaultServer_ [sourceIp] => ncopeland [isPTZEnabled] => false [applicationInstance] => _definst_ [name] => ncopeland [isRecordingSet] => false [isStreamManagerStream] => true [isPublishedToVOD] => false [isConnected] => false [ptzPollingInterval] => false ) So I can work with $obj variable as an array like so. echo $obj['name']; echo $obj['isConnected'];
  16. Thanks, I have read through the Google Maps docs before. That would be useful for static markers but it doesn't help when it comes to dynamic markers and plotting more than one. Also no information on plotting markers from a DB or using JSON triggered off the value of a variable. Looking for suggestions. -Thanks
  17. I have never used cURL before and have hit a roadblock in my learning. I am trying to make a HTTP GET request to my Wowza server which uses the Rest API to return JSON results. I have authentication set to none on the server at the moment until I can get the script working. I have tested the code below with an external website and it works but, when I try to use it with the URL from the server with the Rest API it just times out. I can make the request in a browser fine, just not from the code. What am I missing or not doing correctly? $ch = curl_init("http://IP_TO_SERVER:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/instances/_definst_/incomingstreams/ncopeland"); // such as http://example.com/example.xml curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, 0); $data = curl_exec($ch); curl_close($ch); print $data; The response should be this. { "serverName": "_defaultServer_", "sourceIp": "ncopeland", "isPTZEnabled": false, "applicationInstance": "_definst_", "name": "ncopeland", "isRecordingSet": false, "isStreamManagerStream": true, "isPublishedToVOD": false, "isConnected": true, "ptzPollingInterval": 2000 } -Thanks!
  18. Hello, I am working on a small project and looking for some suggestions on what would be a practical and best way to approach this. I am not proficient at all in javascript and dread working with Google Maps. Here is what I am trying to do. I have a live streaming platform which has about 6 users. All the data I.E. lat/long, heading, geolocation etc is stored in a MySQL DB. The cords are inserted into the DB by a GPS client that is installed on the streamers computer that sends and updates the DB. All that is completed and works perfectly well and great there. What I need to do now is take that data from the DB and plot the users location on map via the cords in the DB but, since they are also constantly moving at times I need for the markers to refresh every X minutes or seconds and on mouseover on the marker show some other details like their name and geolocation which is also stored in the DB. There is a heading field and I have markers for that I need to convert to cardinal direction to display the correct heading icon. I have created a script that connects to the DB and returns a JSON response. What would be the best and easiest way to approach this? Use the JSON file or just use PHP to connect to the DB and create the variables to insert on the map? What is tricky about this is it is fully dynamic so I need some guidance on how to approach this as my Google search hasn't been very successful up to this point. The markers will only be plotted if a certain field in the table is returned as true. If it is true, then plot the marker from the cords in the DB and in the infobox show the other details I.E. Name, Geolocation, etc. One of the things I am struggling with on how to approach this is how to pull all the associated data for a certain user to creating the dynamic marker and infobox details dynamically triggered off a certain field in the DB. If anyone has any suggestions or guidance on how to approach this I would be greatly appreciative. I tried to hire someone to do this part of this small project but had a hard time finding someone that was interested so looks like I will have to do this myself. -Thanks in advance!
  19. Like I mentioned above, I have no desire to be a programmer. I dabble here and there with little one off simple tasks when I can't hire someone to do it because my company is cheap and all they care about is that it works. There problem not mine. Considering what I came up with was based off of countless hours of research and trial and error I think that is a little more than what most people do who just want code handed to them for free. No I didn't try them and I outlined above why. The one thing I have learned over 17yrs dabbling about programming is there is dozens of ways to do something and not everyone is going to agree with everyones methods because it isn't their way of doing it. Maybe even people approached others in a more teaching manner instead of being forceful it might make it easier for others to learn. You want someone to learn, teach them. Don't be forceful and talk down to them. I have a small task list of things I need done. Care to do them for me or teach me in a more practical way? I would certainly hire someone out of my own pocket if I could find someone. After all, this is a "help" forum. I am pretty sure most people didn't come out of the womb knowing the PHP programming language and since I am not a programming or "coder" and have no desire to be then this is my only option and reason I prefer to hire someone than to get beat down on a forum. Thanks for your time and effort. I have my solution and if it doesn't work down the road then that won't be my issue.
  20. It may be common sense for someone who is proficient in PHP but, unlike me I am not therefore it does not make any sense to me. I have no clue where to even insert or how to use the example you posted nor was there any in-depth explanation to learn from. If you want people to learn maybe try better at explaining your solution to those who are not proficient in the PHP programming language instead of talking down to them for not knowing and asking for help as I didn't reject anything, I was just easier to go with what I had already come up with from my other research on the matter than trying to get you to explain it more in-depth in more a understandable way.
  21. 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; }
  22. 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; }
  23. Hello, I am having some issues with some else if statements I am currently working on where if a certain value is equal to a certain number display a certain message else if greater then display a different message. I have tried a number of different combinations without success. What I am trying to accomplish is if the total number of "true" statements from the array is 1 display $notify1Online message and if it is 2 or greater the display the $notifyOnline message else display the $notifyOffline message. I have gone through the PHP manual and done a number of research and played with some different combinations but cannot seem to get this to work. Could someone offer some assistance as to what I am doing wrong. $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']; $total = (in_array("true", $resultArr)); // 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 ( $total = "1" ) { echo $notify1Online; } elseif ( $total < "2" ) { echo $notifyOnline; } else { echo $notifyOffline; } -Thanks!
  24. Ok I appear to have this working. Can someone let me know if this logic seems correct? $resultArr = array();//to store results //to execute 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 } } // Lets assembly 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>'; $notifyOnline = '<div class="alert alert-success" role="alert" data-toggle="tooltip" data-placement="top" title=" "> There are currently X chasers streaming LIVE... </div>'; if (in_array("true", $resultArr)) { echo $notifyOnline; } else { echo $notifyOffline; } -Thanks!
  25. So I am approaching this a little different now instead of trying to go through the JSON file I am just query the DB column and creating an array. Now what I am wanting to do is if any of those values are "true" then echo the $notifyOnline message. If they are all false then echo the $notifyOffline message. I am having an issue getting this to work correctly. Any assistance would be greatly appreciated. Here is what I have come up with as of now. $resultArr = array();//to store results //to execute 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 } } print_r($resultArr);//print the rows returned by query, containing specified columns // Lets assembly 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>'; $notifyOnline = '<div class="alert alert-success" role="alert" data-toggle="tooltip" data-placement="top" title=" "> There are currently X chasers streaming LIVE... </div>'; if ($resultArr == "true") { echo $notifyOnline; } else { echo $notifyOffline; } As you can see from my test URL there is a "true" value in the array therefore it should echo the $notifyOnline message but it isn't. http://www.mesquiteweather.net/stream/inc/test.php -Thanks
×
×
  • 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.