Jump to content

Texan78

Members
  • Content Count

    272
  • Joined

  • Last visited

Everything posted by Texan78

  1. Why on Gods green earth would you ever want to assign your style classes and IDs to the same variable that's outputting data? Lastly, the switch is being used in more than just once script on other areas of the site. Which is why it is being used in a included file so I can pull what I need instead of having to write the logic out every single time across multiple scripts. Which BTW, was something that was suggested by a member of this forum several years ago when that script was originally created. As I have mentioned before as well, that is the thing about PHP and online forums. You will get multiple ways to do the same thing and not everyone is going to agree. Those snippets would probably be useful it you included how to implement it into my current code because this below doesn't work and throws tons of errors. // get path info & protect for cross-site scripting vulnerability $sri = ($_SERVER['REQUEST_URI']) ? str_replace('#SA', '', htmlspecialchars(strip_tags($_SERVER['REQUEST_URI']))) : ''; $error = false; //Set initial output to false $AlertData = false; $entries = simplexml_load_file($data); if(count($entries)): //Registering NameSpace $entries->registerXPathNamespace('prefix', 'http://www.w3.org/2005/Atom'); $result = $entries->xpath("//prefix:entry"); if(!$result){ $error = true; } foreach ($result as $entry): $updated = $entry->updated; if($updated == ''){ $error = true; } $Updated = date("D, M d, g:i a", strtotime($updated)); $summary = $entry->summary; if($summary == ''){ $error = true; } // Replaces all triple periods with single periods $summary = trim(str_replace('...', '.', $summary), '.') . '.'; //now capitalize every letter after a . ? and ! followed by space $Summary = preg_replace_callback('/([.!?*])\s*(\w)/', function ($matches) { return strtoupper($matches[1] . ' ' . $matches[2]); }, ucfirst(strtolower($summary))); $event = $entry->children("cap", true)->event; if($event == ''){ $error = true; } $updated = $entry->updated; $link = $entry->link; $effective = $entry->children("cap", true)->effective; $expires = $entry->children("cap", true)->expires; $updated = date("l M jS, g:i A", strtotime($updated)); $effectiveDate = date("l M jS, g:i A", strtotime($effective)); $expiresDate = date("D M jS, g:i A", strtotime($expires)); $status = $entry->children("cap", true)->status; $severity = $entry->children("cap", true)->severity; $urgency = $entry->children("cap", true)->urgency; $area = $entry->children("cap", true)->areaDesc; //include ('alertColors.php'); $type = array($event); $type['Tornado Warning'] = array('Tornado', 'AlertTornado'); $type['Severe Thunderstorm Warning'] = array('SevereThunderstorm','AlertSevereThunderstorm'); $type['Flash Flood Warning'] = array('FlashFlood','AlertFlood'); $type['Flood Warning'] = array('FlashFlood','AlertFlood'); $alertID = ''; $alertClass = ''; if(isset($type[$event])) { list($alertID,$alertClass) = $type[$event]; } // Let's assign the table some styles $divNoStorms = "padding:5px; width:50%; margin:auto; margin-top:5px; margin-bottom:5px"; // If no storms were in the source, set no storm message if($error) { $AlertData .= "<div style='{$divNoStorms}' class='alert alert-danger' role='alert' data-toggle='tooltip' data-placement='top' title='There are currently no active severe weather alerts.'>\n"; $AlertData .= "{$noStormMessage}\n"; $AlertData .= "</div>\n"; } else { $AlertData .= "<div class='col-md-3'>\n"; $AlertData .= "<div id='{$alertID}' class='individualAlert'>\n"; $AlertData .= "<div class='text_alert'>\n"; $AlertData .= "<span class='title {$alertClass}'><i class='fa fa-exclamation-triangle severe-icon__tornado'></i>{$type}</span>\n"; $AlertData .= "<span class='state'>{$stateShort}</span>\n"; $AlertData .= "<span class='counties'>{$area}</span>\n"; $AlertData .= "<span class='expires'>Expires: {$expiresDate}</span>\n"; $AlertData .= "</div>\n"; $AlertData .= "<div class='alert__view'>\n"; $AlertData .= "<span class='fa fa-eye'></span>\n"; $AlertData .= "</div>\n"; $AlertData .= "</div>\n"; } $AlertData .= "</div>\n"; endforeach; endif; echo $AlertData;
  2. None of that makes any sense to me because I have no idea where that is to be used or how to implement it into my current script. Guess I will have to hire someone for 5 mins to update it.
  3. Well one brain fart solved. This seems to work for producing 4 columns per row. Will need to keep an eye on it to see if it messes up when there isn't equal number of entries. // If no storms were in the source, set no storm message if($error) { $AlertData .= "<div class='alert alert-danger' style='padding:5px;' role='alert' data-toggle='tooltip' data-placement='top' title='There are currently no active severe weather alerts.'>\n"; $AlertData .= "{$noStormMessage}\n"; $AlertData .= "</div>\n"; } else { $AlertData .= "<div class='col-md-3'>\n"; $AlertData .= "<div id='{$alertID}' class='individualAlert'>\n"; $AlertData .= "<div class='text_alert'>\n"; $AlertData .= "<span class='title {$alertClass}'><i class='fa fa-exclamation-triangle severe-icon__tornado'></i> {$event}</span>\n"; $AlertData .= "<span class='state'>{$stateShort}</span>\n"; $AlertData .= "<span class='counties'>{$area}</span>\n"; $AlertData .= "<span class='expires'>Expires: {$expiresDate}</span>\n"; $AlertData .= "</div>\n"; $AlertData .= "<div class='alert__view'>\n"; $AlertData .= "<span class='fa fa-eye'></span>\n"; $AlertData .= "</div>\n"; $AlertData .= "</div>\n"; } $AlertData .= "</div>\n"; endforeach; endif; echo $AlertData; <div class="panel-body" style="background-color: #878787; padding: 5px;"> <div class='row'> <div id="alerts"></div> </div> </div> So last issue is only pulling certain events or in this case "alerts" and prioritizing them so they will show in a certain order. This one seems to be puzzling me.
  4. No worries, long hours in front of a computer can melt your brain for sure. Yes, those are the events and the order of display. Here is the complete script. https://www.tehplayground.com/kjbl8UqUd3EyA0fp
  5. Parsing the XML file is not my issue. The specific nodes I am parsing are in my original post within the first code block. I am able to do that just fine and create variables to insert into the HTML. The issues are as follows... 1. Only show certain events and sort them by priority to show certain ones first. $event = $entry->children("cap", true)->event; if($event == 'Tornado Warning, Severe Thunderstorm Warning, Flash Flood Warning, Flood Warning') 2. Dynamically create the Bootstrap columns (4) for each row to display the parsed information.
  6. //Set path to data file $data = "http://alerts.weather.gov/cap/".$zone.".php?x=0"; $zone is tx
  7. Right, but I am looping through the XML. How can I create them dynamically?
  8. Quick update since it won't let me edit my original post. If I put the Bootstrap in the PHP like so... // If no storms were in the source, set no storm message if($error) { $AlertData .= "<div class='alert alert-danger' style='padding:5px;' role='alert' data-toggle='tooltip' data-placement='top' title='There are currently no active severe weather alerts.'>\n"; $AlertData .= "{$noStormMessage}\n"; $AlertData .= "</div>\n"; } else { $AlertData .= "<div class='row'>\n"; $AlertData .= "<div class='col-md-3'>\n"; $AlertData .= "<div id='Tornado' class='individualAlert'>\n"; $AlertData .= "<div class='text_alert'>\n"; $AlertData .= "<span class='title AlertTornado'><i class='fa fa-exclamation-triangle severe-icon__tornado'></i> {$event}</span>\n"; $AlertData .= "<span class='state'>TX</span>\n"; $AlertData .= "<span class='counties'>{$area}</span>\n"; $AlertData .= "<span class='expires'>Expires: {$expiresDate}</span>\n"; $AlertData .= "</div>\n"; $AlertData .= "<div class='alert__view'>\n"; $AlertData .= "<span class='fa fa-eye'></span>\n"; $AlertData .= "</div>\n"; $AlertData .= "</div>\n"; $AlertData .= "</div>\n"; $AlertData .= "</div>\n"; } endforeach; endif; echo $AlertData; With it in the HTML page like so.... <div class="panel-body" style="background-color: #878787; padding: 5px;"> <?php include ('inc/alerts.php'); ?> </div> It still prints it out down instead of columns of 4 across.
  9. Hello, I am trying to repurpose some old code and update it to use Bootstrap. This is a two part question so I will try to keep it short. First part. I am parsing an XML URL with simpleXML and setting variables to return values to use in some HTML code. This worked great when it was first written years ago but, I need to sort through the values in this case "event" and only show certain events and then sort those show it shows certain ones first before others. For brevity I am only showing the relevant code. // get path info & protect for cross-site scripting vulnerability $sri = ($_SERVER['REQUEST_URI']) ? str_replace('#SA', '', htmlspecialchars(strip_tags($_SERVER['REQUEST_URI']))) : ''; $error = false; //Set initial output to false $AlertData = false; $entries = simplexml_load_file($data); if(count($entries)): //Registering NameSpace $entries->registerXPathNamespace('prefix', 'http://www.w3.org/2005/Atom'); $result = $entries->xpath("//prefix:entry"); if(!$result){ $error = true; } foreach ($result as $entry): $updated = $entry->updated; if($updated == ''){ $error = true; } $Updated = date("D, M d, g:i a", strtotime($updated)); $summary = $entry->summary; if($summary == ''){ $error = true; } // Replaces all triple periods with single periods $summary = trim(str_replace('...', '.', $summary), '.') . '.'; //now capitalize every letter after a . ? and ! followed by space $Summary = preg_replace_callback('/([.!?*])\s*(\w)/', function ($matches) { return strtoupper($matches[1] . ' ' . $matches[2]); }, ucfirst(strtolower($summary))); $event = $entry->children("cap", true)->event; if($event == 'Tornado Warning, Severe Thunderstorm Warning, Flash Flood Warning'){ $error = true; } $updated = $entry->updated; $effective = $entry->children("cap", true)->effective; $expires = $entry->children("cap", true)->expires; $updated = date("l M jS, g:i A", strtotime($updated)); $effectiveDate = date("l M jS, g:i A", strtotime($effective)); $expiresDate = date("l M jS, g:i A", strtotime($expires)); $status = $entry->children("cap", true)->status; $severity = $entry->children("cap", true)->severity; $urgency = $entry->children("cap", true)->urgency; $area = $entry->children("cap", true)->areaDesc; Take notice to this insert below from the code above where I have defined what events to show. So it should only show those events but, instead it still shows all of them. $event = $entry->children("cap", true)->event; if($event == 'Tornado Warning, Severe Thunderstorm Warning, Flash Flood Warning') Second part is I need this to show in 4 columns across in one row but, it just displays them down. I have experimented with some but not sure how to currently place the bootstrap code so it displays 4 columns per row then starts a new row. The image below shows the output going down. The yellow and green are hard coded for example of what I am wanting it to do. Here is the code for the output in red that is going down when it should be going across. // If no storms were in the source, set no storm message if($error) { $AlertData .= "<div class='alert alert-danger' style='padding:5px;' role='alert' data-toggle='tooltip' data-placement='top' title='There are currently no active severe weather alerts.'>\n"; $AlertData .= "{$noStormMessage}\n"; $AlertData .= "</div>\n"; } else { $AlertData .= "<div id='Tornado' class='individualAlert'>\n"; $AlertData .= "<div class='text_alert'>\n"; $AlertData .= "<span class='title AlertTornado'><i class='fa fa-exclamation-triangle severe-icon__tornado'></i> {$event}</span>\n"; $AlertData .= "<span class='state'>TX</span>\n"; $AlertData .= "<span class='counties'>{$area}</span>\n"; $AlertData .= "<span class='expires'>Expires: {$expiresDate}</span>\n"; $AlertData .= "</div>\n"; $AlertData .= "<div class='alert__view'>\n"; $AlertData .= "<span class='fa fa-eye'></span>\n"; $AlertData .= "</div>\n"; $AlertData .= "</div>\n"; } endforeach; endif; echo $AlertData; Then the raw HTML code. <div class="row"> <div class="col-md-3"> <!-- <span>Active Tornado Warnings</span> --> <?php include ('inc/alerts.php'); ?> </div> <div class="col-md-3"> <!-- <span>Active Severe Thunderstorm Warnings</span> --> <div id="SevereThunderstorm" class="individualAlert"> <div class="text_alert"> <span class="title AlertSevereThunderstorm"><i class="fa fa-exclamation-triangle severe-icon__thunderstorm"></i> SEVERE THUNDERSTORM WARNING TEST</span> <span class="state">TX</span> <span class="counties">DALLAS</span> <span class="expires">Expires: 12:00 PM CST</span> </div> <div class="alert__view"> <span class="fa fa-eye"></span> </div> </div> </div> <div class="col-md-3"> <!-- <span>Active Flash Flood Warnings</span> --> <div id="FlashFlood" class="individualAlert"> <div class="text_alert"> <span class="title AlertFlood"><i class="fa fa-exclamation-triangle severe-icon__flood"></i> FLASH FLOOD WARNING TEST</span> <span class="state">TX</span> <span class="counties">DALLAS</span> <span class="expires">Expires: 12:00 PM CST</span> </div> <div class="alert__view"> <span class="fa fa-eye"></span> </div> </div> </div> <div class="col-md-3"> <!-- <span>Active Flash Flood Warnings</span> --> <div id="FlashFlood" class="individualAlert"> <div class="text_alert"> <span class="title AlertFlood"><i class="fa fa-exclamation-triangle severe-icon__flood"></i> FLASH FLOOD WARNING TEST</span> <span class="state">TX</span> <span class="counties">DALLAS</span> <span class="expires">Expires: 12:00 PM CST</span> </div> <div class="alert__view"> <span class="fa fa-eye"></span> </div> </div> </div> </div> I am sure I need to add <div class="row"> <div class="col-md-3"> in my PHP code but I am not sure how and the things I have tried had not worked. -Thanks
  10. I said never mind, I got it sorted. You can now take your arrogance and excuse yourself from this thread as this is the second time you've talked down to me.
  11. Never mind, I got it sorted with the following. <div class="right"> <h3 class="panel-title"> <?php if ($ncopeland['streamStatus'] == 'true' ) { echo '<span class="label label-success"><i class="fa fa-video-camera" title="Stream Online"></i> LIVE</span> <i class="fa fa-eye" aria-hidden="true" title="Current Viewers ' . $ncopeland['CurrentViewers'] . '"> <span style="font-size:12px;font-weight:bold; font-family: arial,helvetica;">' . $ncopeland['CurrentViewers'] . '</span>'; } else { echo '<span class="label label-important"><i class="material-icons" style="vertical-align:-4px; font-size:14px;" title="Steam Offline">videocam_off</i> OFFLINE</span>'; } ?></i> </h3> </div>
  12. For what I am trying to do this is not simplified, especially when using it in javascript versus using just $variable. Anyways, I am just going to roll with it and learn it as for what I am doing at this very moment it is sleek and compact for making unique variables and prevents duplicates when make multiple queries on a single page. With that said, I am not sure how to put this into HTML like I was doing before with this new method. How would I go about replacing the $CurrentViewers with $ksaunders['CurrentViewers'] as there is two places I need to add it and it's being used in HTML. Can I get an example please on how to properly insert and escape this? <div class="right"> <h3 class="panel-title"> <?php if ($ksaunders['streamStatus'] == 'true' ) { echo "<span class='label label-success'><i class='fa fa-video-camera' title='Stream Online'></i> LIVE</span> <i class='fa fa-eye' aria-hidden='true' title='Current Viewers $CurrentViewers'> <span style='font-size:12px;font-weight:bold; font-family: arial,helvetica;'>$CurrentViewers</span>"; } else { echo "<span class='label label-important'><i class='material-icons' style='vertical-align:-4px; font-size:14px;' title='Steam Offline'>videocam_off</i> OFFLINE</span>"; } ?></i> </h3> </div> Also would this be the proper way to add a space before a variable? echo ' ' .$ksaunders['DisplayName']; -Thanks
  13. I am sorry but I am having a hard time understanding what you're trying to say. None of that makes any sense to me at all. Using $row["DisplayName"] is not a simplified method versus using $DisplayName in my code nor is that a variable. Maybe you're misunderstanding what I am trying to say. Is there more to this code that I am missing? $sql = "SELECT gpsStatus, DisplayName, ChaserLocation, StreamStatus, CurrentViewers, TimeStamp FROM streamdb WHERE id = 1"; $result = $mysqli->query($sql); $stream_data = $result->fetch_assoc(); This is the only way I can get it to work for what I am needing. /* Lets query the database and return the current values */ $sql = "SELECT gpsStatus, DisplayName, ChaserLocation, StreamStatus, CurrentViewers, TimeStamp FROM streamdb WHERE id = 2"; $result = $mysqli->query($sql); $stream_data = $result->fetch_assoc(); printf ("\n",$gpsStatus = $stream_data["gpsStatus"],$DisplayName = $stream_data["DisplayName"],$chaserLocation = $stream_data["ChaserLocation"],$status = $stream_data["StreamStatus"],$totalViewers = $stream_data["CurrentViewers"],$timeStamp = $stream_data["TimeStamp"]);
  14. There is only one code sample which is on post 7 and it didn't apply to what I am trying to accomplish nor was it useful?
  15. Because I created them. The code suggested suggests I don't have to do that anymore. So then how to I access the data from the fields if there is no variable assigned to it?
  16. 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?
  17. 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!
  18. 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!
  19. 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';
  20. 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
  21. 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.
  22. 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
  23. 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.
  24. 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!
  25. 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!
×
×
  • 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.