Jump to content

Texan78

Members
  • Posts

    272
  • Joined

  • Last visited

Everything posted by Texan78

  1. 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. So I guess I just fantasized that someone gained root access via shell. So I guess it is completely valid to comment out the entire query which renders the entire script useless. So I guess that if I uncomment the DB connection it will work perfectly fine with no errors correct? That is what you're saying right? Guess what, it is uncommented, the errors have returned. So now what all mighty know it all? What does your magic 8 ball have to say about that? Cool story bro? Yeah stick it keyboard warrior.
  3. Genius!!! Even better I should just remove the entire query! That should do the trick!
  4. Again, the errors were happening BEFORE I commented out the code. I commented it out because it was throwing errors in the logs BEFORE commenting it out. It was also causing performance and resource issues on my host which was causing the page not to load. I commented it out in the script AND on the page it was being included on until I could resolve the issue. Once I did both those things the page loaded AND the errors went away.
  5. Yes, it is commented out because it was causing serious issues with the page loading so I commented it out until I could get this sorted.
  6. I have a serious issue. I am not sure if I have been hacked or what but my site is completely messed up. I have a ton of these errors in the error log and I am not sure what is causing this. I don't recall this being part of the script Which is referring to this line. //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 } } This is the full code. /* Lets connect to the database */ //include('dbconn.php'); $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']; // Let's assign the table some styles $divStyle = "padding:5px; margin:auto; margin-bottom:20px"; // Lets assemble the banners to display $notifyOffline = "<div class='alert alert-danger' style='{$divStyle}' role='alert' data-toggle='tooltip' data-placement='top' title='There are currently no chasers streaming at this time.'> There are currently no chasers streaming at this time.</div>"; $notify1Online = "<div class='alert alert-success' style='{$divStyle}' role='alert' data-toggle='tooltip' data-placement='top' title='There is currently 1 chaser streaming LIVE...'> There is currently 1 chaser streaming LIVE... </div>"; $notifyOnline = "<div class='alert alert-success' style='{$divStyle}' role='alert' data-toggle='tooltip' data-placement='top' title='There are currently ".$online." chasers streaming LIVE...'> 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; } Any and ALL help would be greatly welcomed. -THANKS!
  7. Still looking for a solution to this that implements into my current script that will filter certain values and then sort them.
  8. Still no solution to what I think is a very simple question.
  9. Should I guess how to implement those snippets or you going to show me an example of how to implement it into my current code since you're not making any sense or listening to anything I am saying. I also can't ditch the IF statement because it is doing two different things as it is suppose to. Have you ever heard of the KISS method?
  10. This is doing just that. What is set in the array is style classes and IDs. From what I can tell that is assigning it to the same variable $type. This is the alert or event ['Tornado Warning'] and these are styles array('Tornado', 'AlertTornado'); $type = array(); $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'); How else am I going to pass the values to it to filter out what I want? It's not just going to know if you don't pass something to it to filter through. Like I said, those snippets would probably be useful it you included examples of how to implement it into my current code.
  11. 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;
  12. 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.
  13. 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.
  14. 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
  15. 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.
  16. //Set path to data file $data = "http://alerts.weather.gov/cap/".$zone.".php?x=0"; $zone is tx
  17. Right, but I am looping through the XML. How can I create them dynamically?
  18. 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.
  19. 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
  20. 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.
  21. 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>
  22. 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
  23. 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"]);
  24. 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?
  25. 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?
×
×
  • 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.