Jump to content

RADaugherty

Members
  • Posts

    12
  • Joined

  • Last visited

Everything posted by RADaugherty

  1. Oh damn! So just changing that to an "s" for a string should fix my issue! I knew it had to be something simple. Thanks a lot!
  2. So I pass header data to a PHP file and execute an UPDATE statement based on that. The header data comes through correctly but instead of updating it via the WHERE it just updates all rows. Can someone tell me what I'm doing wrong? The header data will look like this: Battery-0975GJ <?php include "config.php"; if (isset($_GET['Header'])){ $headerData =$_GET['Header']; $headerDataB = explode("|", $headerData); if (is_array($headerDataB)) { $headerData = $headerDataB[0] . " " . $headerDataB[1]; } $contentVar = "True"; $conn=mysqli_connect($host,$user,$password,$dbname); if(!$conn){ die('Could not Connect MySql Server:' .mysql_error()); } $headerData = str_replace(['+', '<', '>', '(', ')', '~', '*', '\'', '"'], '', $headerData); echo $headerData; $sql="UPDATE ServicePending SET Tag = ? WHERE SystemID = ? "; $stmt=$conn->prepare($sql); $stmt->bind_param("si",$contentVar,$headerData); $stmt->execute(); // echo '<script type="text/javascript">'; //echo 'alert("Battery has been updated!");'; //echo 'window.location.href = "attentionbatteries.php";'; //echo '</script>'; } ?> Added in the echo $headerData; just for testing and uncommented the javascript section until I get this figured out. SystemID is 100% unique after the "Battery-" but since I'm not doing a LIKE I can't figure out why its updating more than just that one with the SystemID found in the header data. Thanks!
  3. So I have a universal Navigation bar that I include on all my pages to navigate ect... but I'm having a lot of issues with what happens after I navigate to a page that's in a sub folder. <script> $(document).ready(function(){ $('#header').load("navbar.html"); }); </script> This is how I include the navbar in each of the pages. Here is how I THINK the Navbar should be setup (All pages work fine except for the bottom 3, which are in a sub folder called BMSCalendar <div class="navbar"> <a href="index.php">Dashboard</a> <div class="dropdown"> <button class="dropbtn">Assignments <i class="fa fa-caret-down"></i> </button> <div class="dropdown-content"> <a href="workassignments.php">Work Assignments</a> <a href="officeassignments.php">Office Assignments</a> </div> </div> <div class="dropdown"> <button class="dropbtn">Fleet Management <i class="fa fa-caret-down"></i> </button> <div class="dropdown-content"> <a href="loanerOverview.php">Loaner Fleet</a> <a href="stockOverview.php">Stock Fleet</a> <a href="tmmiOverview.php">TMMI Fleet</a> <a href="equipmentOverview.php">Equipment Shipping</a> </div> </div> <a href="attentionbatteries.php">Discharge Batteries</a> <a href="ViewInventory.php">Inventory Viewer</a> <div class="dropdown"> <button class="dropbtn">Schedule <i class="fa fa-caret-down"></i> </button> <div class="dropdown-content"> <a href="/BMSCalendar/Calendar.php">Work Schedule</a> <a href="/BMSCalendar/index.php">Board Schedule</a> <a href="/BMSCalendar/searchSchedule.php">Search Schedule</a> </div> </div> </div> So the website is www.xxxxxxxx.net/TestDash/index.php When I am on index and I navigate to any of the pages in that dir everything works 100% fine. Now if I go to the Schedule section and select one it fails and the address is www.xxxxxxxx.net/BMSCalendar/Calendar.php instead of www.xxxxxxxx.net/TestDash/BMSCalendar/Calendar.php Now if I change it to: <a href="../TestDash/BMSCalendar/searchSchedule.php">Search Schedule</a> It works but then if I try and navitage to any of the other pre-existing pages (Index ect.) that worked, it fails and the address now is: https://www.xxxxxxxx.net/TestDash/BMSCalendar/index.php Haaaaaaaaaaaaalp! I assume I'm just misunderstanding how a href works but I'm not sure
  4. I'm going to mark this as solved for now! Thanks for leading me in the right direction requinix! A good start to my website I think!
  5. Idiot 2.0 I had <div class="shipLineData"> Instead of <div id="shipLineData"> And a . instead of # here $('.shipLineData').load('shipline.php'); -> $('#shipLineData').load('shipline.php'); All seems to be working now!
  6. Hello! No I don't see any errors. I am using GoDaddy with CPanel so as far as I know the only information I get is in the "error_log" file it generates if theres an error but nothing is written in there. I'm a dope, I am just now learning web development so I didn't realize Chrome had a built in console viewer. This is being thrown, I'll dig into it and see if I can figure out why! Looks like I needed to add in the reference to JQuery is all! Added that in and I'm now seeing the alertbox so I'll keep testing! As of right now it says I am updating the data but if I change my test echo from shipline.php I don't get that change until I manually refresh the page.
  7. Not sure the best place to post this but seeing as the actual hiccup seems to be in the JS side of the call I'm throwing it here. Breakdown 1: Page Loads 2: Set interval to call Div of "shipLineData" to update MySQL Table data 3: Load initial Div/Data (Can see all the table info) - Added in a "test1" echo at the bottom so I can just change that without having to change MySQL data to test refresh 4: Nothing happens (Added alert box for testing, it never fires) 5: Can remove the "$('.shipLineData').load('shipline.php');" from the function and now the alert box shows up. Index page <!DOCTYPE html> <html lang="en"> <head> <!-- Style for Tables !--> <style> * { box-sizing: border-box; } .row { display: flex; margin-left:-5px; margin-right:-5px; } .column { flex: 50%; padding: 5px; } table { border-collapse: collapse; border-spacing: 0; width: 100%; border: 1px solid #ddd; } th { text-align: left; padding: 16px; font-size: 130%; font-weight: bold; color: orange; } td { text-align: left; padding: 16px; font-size: 90%; font-weight: bold; } tr:nth-child(even) { background-color: #f2f2f2; } caption { text-align: center; margin-bottom: 5px; font-size: 100%; padding: 5px; letter-spacing: 2px; font-weight: bold; } </style> </head> <body> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> setInterval( refreshTables, 5000 ); var inRequest = false; function refreshTables() { $('.shipLineData').load('shipline.php'); window.alert("test"); } </script> <div class="shipLineData"> <div class="row"> <div class="column"> <?php include('shipline.php')?> </div> </div> </div> </body> </html> shipline.php w/ table creation <?php $servername = "localhost"; $username = "xxxx"; // User $password = "xxxx"; $dbname = "xxxxx"; $results = array(); unset($results); $results = array(); $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $stmt = $conn->prepare("SELECT SystemID, ServiceOrder FROM ServicePending"); $stmt->execute(); $i = 0; $stmt->bind_result($ID, $WO); while ($stmt->fetch()) { $i += 1; $results[$i] = array('SystemID' => $ID, 'ServiceOrder' => $WO); } $count = count($results); $i = 1; echo "<table id='shipLineTable'>"; echo "<tr>"; echo "<caption>Ready to Ship</caption>"; echo "<th>Serial Number</th>"; echo "<th>Work Order Number</th>"; echo "</tr>"; while ($i < $results && $i < $count + 1) { echo "<tr>"; echo "<td>" . $results[$i]["SystemID"] . "</td>"; echo "<td>" . $results[$i]["ServiceOrder"] . "</td>"; echo "</tr>"; $i++; } echo "</table>"; echo "test1"; ?>
  8. Hmm, I'm fairly newb with PHP as I'm just using it for this type of service I provide for people on another forum but I don't think that would accomplish the same thing I need. If you check my About Me section ( didn't see a section for signature ) you'll see it shows the image there
  9. I did look at ImageMagick a little but I didn't see a way of presenting the webpage as just an image like I do with GD (as opposed to showing the image on a webpage) if that makes sense. Thanks!
  10. So I've worked with PNG/JPG's before with overlaying text onto an image and then displaying said image. Now I want to use a Gif and do the same thing, but the image loses its animation. Is there a way to do this? Specifically, I use these in signatures on forums and as such I have the file name like this; Website.png.php so that the forum sees the extension and allows an image to be shown. Is there anything out that where I can accomplish this using a Gif? Note: I would be content without the ability of overlaying text onto the Gif so long as I can display them using this address type that the forum allows in signatures. Here's the image I can work with https://www.radproducts.me/LSSigs/tizzoe.png[/IMG] And here's the code behind it. <?php Header ('Content-type: image/jpeg'); Header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); Header('Expires: Thu, 19 Nov 1981 08:52:00 GMT'); Header('Pragma: no-cache'); /****************************************************** * BASICS * ******************************************************/ // set some dimensions for future use $expbar_width = 100; $expbar_height = 25; // set the background colour // number or is top left pixel x, top left pixel y, bottom right pixel x, bottom right pixel y // set the font and print text $namefont = '../Fonts/Squared Display.ttf'; $font = '../Fonts/AldotheApache.ttf'; $hpfont = '../Fonts/AldotheApache.ttf'; $guildfont = '../Fonts/Fragment.otf'; /****************************************************** * LOAD DATA * ******************************************************/ // Create an array for determining the class you play. // In the XML this is saved as an int number, the conversion is shown below. $class_name = array( -1 => 'None', 0 => 'Fighter', 1 => 'Barbarian', 2 => 'Rogue', 3 => 'Magician', 4 => 'Guardian', 5 => 'Samurai', 6 => 'Paladin', 7 => 'Monk', 8 => 'Ninja', 9 => 'Warlock', 10 => 'Headhunter', 11=> 'Alchemist'); // load xml data in vars // This is where you load your own info from the xml d2jsp gives. This is a PHP5 only command! $data = simplexml_load_file('http://ladderslasher.d2jsp.org/xmlChar.php?i=135032'); $guild = simplexml_load_file('http://ladderslasher.d2jsp.org/xmlGuild.php?i=2280'); $name = $data->name; $kills = $data->kills; $class = $class_name[(int)$data->classid]; $exp = $data->exp; $level = $data->level; $gps = getMemberGps($guild, 'tizzoe')['gps']; $hpmax = $data->hpmax; $mpmax = $data->mpmax; $str = $data->strength; $dex = $data->dexterity; $vit = $data->vitality; $int = $data->intelligence; $mqpasses = $data->mqpasses; $mqattempts = $data->mqattempts; $exp = (int)$exp; $temp = explode(";",$data->cprof); foreach ((array) $temp as $value) { $temp2 = explode(",",$value); $cprof[(int)$temp2[0]] = (int)$temp2[1]; } $temp3 = explode(";",$data->wprof); foreach ((array) $temp3 as $value) { $temp4 = explode(",",$value); $wprof[(int)$temp4[0]] = (int)$temp4[1]; } $temp5 = explode(";",$data->sprof); foreach ((array) $temp5 as $value) { $temp6 = explode(",",$value); $sprof[(int)$temp6[0]] = (int)$temp6[1]; } $sword = $wprof[0]; $club = $wprof[1]; $axe = $wprof[2]; $dagger = $wprof[3]; $staff = $wprof[4]; $longsword = $wprof[5]; $warhammer = $wprof[6]; $battleaxe = $wprof[7]; $spear = $wprof[8]; $polearm = $wprof[9]; $ice = $cprof[0]; $fire = $cprof[1]; $lightning = $cprof[2]; $wind = $cprof[3]; $earth = $cprof[4]; $wheal = $cprof[5]; $heal = $cprof[6]; $focus = $cprof[7]; $fishing = $sprof[0]; $cooking = $sprof[1]; $glyphing = $sprof[2]; $transmuting = $sprof[3]; $suffusencing = $sprof[4]; //$percent = calcExpPercent($exp); //$brpixelX = calcBrPixelX($exp,$expbar_width); // Create an expbar with bg 'cool' color and the cover of your level in red. //imagefilledrectangle($image, 80, 27, 160, 37, $cool); //imagefilledrectangle($image, 80, 27, $brpixelX, 37, $barb); //imagefilledrectangle($image, 80, 27, 100, 37, $cool); //imagefilledrectangle($image, 80, 37, $brpixelX, 27, $red); /****************************************************** * TEXT PART * ******************************************************/ //Example; ImageTTFText ($image, textsize, angle, right indent, down indent, color, font, "text"); $random = rand(0, 1); if ($random === 0) { $image = imagecreatefromjpeg('../LSImages/ElephantB.jpg'); // set some colours for future use $cool = imagecolorallocate($image, 255, 255, 102); $red = imagecolorallocate($image, 255, 255, 255); $yellow = imagecolorallocate($image, 235, 141, 54); if ($class === 'None') { $image = imagecreatefromjpeg('../LSImages/None.jpg'); } if ($class != 'None') { //show name ImageTTFText ($image, 20, 0, 255, 33, $red, $guildfont, $name); //show class ImageTTFText ($image, 12, 0, 275, 50, $red, $font, "Class: "); ImageTTFText ($image, 12, 0, 315, 50, $cool, $font, $class); // show lvl ImageTTFText ($image, 12, 0, 295, 64, $red, $font, "Level: "); ImageTTFText ($image, 12, 0, 335, 64, $cool, $font, $level); // show Str ImageTTFText ($image, 10, 0, 260, 80, $red, $font, "Str: "); ImageTTFText ($image, 10, 0, 290, 80, $cool, $font, $str); // show Dex ImageTTFText ($image, 10, 0, 340, 80, $red, $font, "Dex: "); ImageTTFText ($image, 10, 0, 370, 80, $cool, $font, $dex); // show Vit ImageTTFText ($image, 10, 0, 260, 95, $red, $font, "Vit: "); ImageTTFText ($image, 10, 0, 290, 95, $cool, $font, $vit); // show Int ImageTTFText ($image, 10, 0, 340, 95, $red, $font, "Int: "); ImageTTFText ($image, 10, 0, 370, 95, $cool, $font, $int); // show kills ImageTTFText ($image, 12, 0, 280, 119, $red, $font, "Kills: "); ImageTTFText ($image, 12, 0, 322, 119, $cool, $font, $kills); //show experience ImageTTFText ($image, 12, 0, 285, 132, $red, $font, "Exp: "); ImageTTFText ($image, 12, 0, 310, 132, $cool, $font, $exp); // SHow MQ passen and attempts ImageTTFText ($image, 10, 0, 260, 146, $red, $font, "MQs: "); ImageTTFText ($image, 10, 0, 290, 146, $cool, $font, $mqpasses." / ".$mqattempts); // Show guild points ImageTTFText ($image, 10, 0, 355, 146, $red, $font, "GPs: "); ImageTTFText ($image, 10, 0, 385, 146, $cool, $font, $gps); } } if ($random === 1) { $image = imagecreatefromjpeg('../LSImages/tizzoeC.jpg'); // set some colours for future use $cool = imagecolorallocate($image, 153, 51, 255); $red = imagecolorallocate($image, 51, 51, 255); $yellow = imagecolorallocate($image, 255,255,255); if ($class === 'None') { $image = imagecreatefromjpeg('../LSImages/None.jpg'); } if ($class != 'None') { //show name ImageTTFText ($image, 20, 0, 240, 33, $yellow, $guildfont, $name); //show class ImageTTFText ($image, 12, 0, 260, 50, $red, $font, "Class: "); ImageTTFText ($image, 12, 0, 300, 50, $cool, $font, $class); // show lvl ImageTTFText ($image, 12, 0, 280, 64, $red, $font, "Level: "); ImageTTFText ($image, 12, 0, 320, 64, $cool, $font, $level); // show Str ImageTTFText ($image, 10, 0, 245, 80, $red, $font, "Str: "); ImageTTFText ($image, 10, 0, 275, 80, $cool, $font, $str); // show Dex ImageTTFText ($image, 10, 0, 325, 80, $red, $font, "Dex: "); ImageTTFText ($image, 10, 0, 355, 80, $cool, $font, $dex); // show Vit ImageTTFText ($image, 10, 0, 245, 95, $red, $font, "Vit: "); ImageTTFText ($image, 10, 0, 275, 95, $cool, $font, $vit); // show Int ImageTTFText ($image, 10, 0, 325, 95, $red, $font, "Int: "); ImageTTFText ($image, 10, 0, 355, 95, $cool, $font, $int); // show kills ImageTTFText ($image, 12, 0, 265, 119, $red, $font, "Kills: "); ImageTTFText ($image, 12, 0, 307, 119, $cool, $font, $kills); //show experience ImageTTFText ($image, 12, 0, 260, 132, $red, $font, "Exp: "); ImageTTFText ($image, 12, 0, 295, 132, $cool, $font, $exp); // SHow MQ passen and attempts ImageTTFText ($image, 10, 0, 245, 146, $red, $font, "MQs: "); ImageTTFText ($image, 10, 0, 275, 146, $cool, $font, $mqpasses." / ".$mqattempts); // Show guild points ImageTTFText ($image, 10, 0, 340, 146, $red, $font, "GPs: "); ImageTTFText ($image, 10, 0, 370, 146, $cool, $font, $gps); } } // output and destroy imagejpeg($image, null, 100); imagedestroy($image); /****************************************************** * FUNCTIONS * ******************************************************/ /*** * calculate the exp bar width. ***/ function calcBrPixelX($input,$xpbar_width) { $temp1 = fmod($input,1000000); $temp1 = ($temp1/1000000); $temp1 = $temp1 * $xpbar_width; $temp1 = $temp1 + 80; return (int)$temp1; } /*** * Calculate the percentage of level done ***/ function calcExpPercent($input) { $temp1 = fmod($input,1000000); $temp1 = ($temp1/1000000); $temp1 = $temp1 * 100; return (int)$temp1; } function getMemberGps($guild, $name) { foreach ($guild as $member) { if (reset($member['name']) === $name) { return reset($member); } } return false; } ?>
  11. So I was able to resolve this, it was indeed the SSL that broke it. Inside the graph.js's the link was to https://www.radproducts.com/WeatherData/getTempData.php But switching to url : "../WeatherData/getHumData.php", Was the fix.
  12. So I've got some graphs that I am pulling data down from a MySQL server and it was all seemingly working last night, could see Data/Graphs but today it isn't. One thing I changed was I installed an SSL Cert on the website but that shouldn't break the graphs... I think? This is my webpage code. <html> <style> .parent { border: 1px solid black; margin: 1rem; padding: 1rem 1rem; text-align: center; } .child { display: inline-block; border: 1px solid red; padding: 1rem 1rem; vertical-align: middle; width: 700px; } </style> <head> <!-- javascript --> <script type="text/javascript" src="https://www.radproducts.me/WeatherData/js/jquery.min.js"></script> <script type="text/javascript" src="https://www.radproducts.me/WeatherData/js/Chart.min.js"></script> <script type="text/javascript" src="https://www.radproducts.me/WeatherData/js/tempgraph.js"></script> <script type="text/javascript" src="https://www.radproducts.me/WeatherData/js/humgraph.js"></script> <script type="text/javascript" src="https://www.radproducts.me/WeatherData/js/prsgraph.js"></script> <script type="text/javascript" src="https://www.radproducts.me/WeatherData/js/wspdgraph.js"></script> </head> <body> <center> <h1>Graphs</h1> <div class='parent'> <div class='child'><canvas id="tempgraph"></canvas></div> <div class='child'><canvas id="humgraph"></canvas></div> <br><br> <div class='child'><canvas id="prsgraph"></canvas></div> <div class='child'><canvas id="wspdgraph"></canvas></div> </div> </center> </body> </html> This code grabs the MySQL Data and outputs it to JSON for the graph to read. <?php //setting header to json header('Content-Type: application/json'); //database define('DB_HOST', '*****'); define('DB_USERNAME', '*****'); define('DB_PASSWORD', '******'); define('DB_NAME', '******'); //get connection $mysqli = new mysqli(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME); if(!$mysqli){ die("Connection failed: " . $mysqli->error); } //query to get data from the table $query = sprintf("SELECT temp,time FROM currentWeather"); //execute query $result = $mysqli->query($query); //loop through the returned data $data = array(); foreach ($result as $row) { $data[] = $row; } //free memory associated with result $result->close(); //close connection $mysqli->close(); //now print the data print json_encode($data); This code takes the JSON readout and puts it into a graph for me to use. $(document).ready(function(){ $.ajax({ url : "https://radproducts.me/WeatherData/getTempData.php", type : "GET", success : function(data){ console.log(data); var temps = []; var times = []; for(var i in data) { times.push(data[i].time); temps.push(data[i].temp); } var chartdata = { labels: times, datasets: [ { label: "times", fill: false, lineTension: 1, backgroundColor: "rgba(59, 89, 152, 0.75)", borderColor: "rgba(59, 89, 152, 1)", pointHoverBackgroundColor: "rgba(59, 89, 152, 1)", pointHoverBorderColor: "rgba(59, 89, 152, 1)", data: times }, { label: "temps", fill: false, lineTension: 0.1, backgroundColor: "rgba(29, 202, 255, 0.75)", borderColor: "rgba(29, 202, 255, 1)", pointHoverBackgroundColor: "rgba(29, 202, 255, 1)", pointHoverBorderColor: "rgba(29, 202, 255, 1)", data: temps } ] }; var ctx = $("#tempgraph"); var LineGraph = new Chart(ctx, { type: 'line', data: chartdata }); }, error : function(data) { } }); }); js folder structure is Chart.min.js jquery.min.js humgraph.js prsgraph.js tempgraph.js wspdgraph.js Any thoughts??
×
×
  • 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.