PHP - Using File_get_contents For Vote Incentives
Hi, I run a top site which has incentives. Originally when a voter came and voted, the script in the background would run file() but I noticed that it sometimes lagged and caused the voter to wait a few secs before the page loads.
I was then told by a developer to use file_get_contents(), but I was getting the same results. It occasionally lagged, even on my own websites that are voting on it. I decided to log the incentives now, and get a cron to check and process any incentives instead of the user lagging, but now it's starting to kill my server as you can see below Quote xxxxx.com 1.05 0.49 0.1 Top Process %CPU 77.2 php -q process_incentives.php Top Process %CPU 24.0 php -q process_incentives.php Top Process %CPU 8.0 php -q timers/5mins.php xxxxx.com 0.99 0.13 0.0 Top Process %CPU 9.0 php -q timers/30mins.php Top Process %CPU 7.0 php -q timers/5mins.php Code in process_incentives.php //REWARD VOTERS $get = mysql_query("SELECT id,url FROM incentives ORDER BY id DESC limit 50;"); while ($game = mysql_fetch_array($get)){ file_get_contents("$game[url]"); mysql_query("DELETE from incentives WHERE id='$game[id]'"); } Similar TutorialsThis topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=322815.0 I have a small site that is based around maxbounty offers (incentives for leads as such) and I can't seem to work out a good way to adjust the database entry for 'currency' when the callback is performed.
Basically, I just need help finding a (fairly) secure php script (http://www.maxbounty.../help.cfm?id=12) that connects to my database and adjusts the user's balance to a certain amount on the call back.
In addition, one to deduct from the balance on call would also help heaps!
Is anybody able to help out?
I get to errors below and cannot figure out what im doign wrong i've tryed diffrent ways and have even rewritten this couple times (#1error) not sure how to re query and echo out the array?? (#2error) gives me error on line 14 if i echo anything past (echo $row['name']."|user1:". $row['user1']. "|user2:". $row['user2']. ->this Code: [Select] <?php $conn = mysql_connect("localhost", "root", ""); if (!$conn) { echo "Unable to connect to DB: " . mysql_error(); } if (!mysql_select_db("register_db")) { echo "Unable to select mydbname: " . mysql_error(); exit; } $result = mysql_query("SELECT * FROM register_vote WHERE name = '{$_POST['user']}'"); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } =========================(#1error)========================================== //THIS IS THE CODE I'M HAVING ISSUES WITH if (mysql_num_rows($result) == 0) { mysql_query("INSERT INTO register_vote (name) VALUES ('$_POST[user]')"); //need it to the query new results after insert //then // echo $row['name']."|user1:". $row['user1']. "|user2:". $row['user2']. "|user3:". $row['user3']; }================================================= (#2error)=================================== while ($row = mysql_fetch_array($result)) { echo $row['name']."|user1:". $row['user1']. "|user2:". $row['user2']. "|user3:". $row['user3']; } //when I put anything past $row['user2']. it gives me error on line 14 mysql_free_result($result); ?> Hello, I have built a blog in php but. On each article in the blog people are able to comment. I would now like to build a system where people can vote on the comment up/down with Ajax. In my comments database I have a table that looks like this: id / article_id / user_id / dateposted / comment / voteup / votedown I would like it to look like this: Any ideas how I can do this? Tutorials online? Thanks a million Hi im trying to Make a Timer count down in this code function getTime($host, $user, $pass, $db, $hours, $ip, $serverId) { $c = @mysql_connect($host, $user, $pass); if(mysql_select_db($db, $c)) { $dateQ = mysql_query('SELECT MAX(date) AS lastVoteDate FROM `'. $db .'`.`votes` WHERE ip="'. $ip .'"') or die(mysql_error()); $getDate = mysql_fetch_assoc($dateQ); $diffrence = time() - strtotime($getDate['lastVoteDate']); $hours = number_format(($diffrence / 60 / 60)); $minutes = number_format(($hours / 60)); if(!$hours < 1){ return ("". $hours .""); } else { return ("0"); } } else { return array(1, "Error connecting to DB."); } } Hi everyone, I have a like button on repeating regions that is used for keeping a record of votes on comments. People click it an it adds 1 to the votes column total. It works just fine. Problem is i only want to a allow a user one vote per comment only. can vote on other comments as well, but again, only one vote per day per comment. i wouldn't know where to start. Would i use a cookie or record an ip? switch ($_REQUEST['action']) { case 'likeit'; foreach($_REQUEST as $key=>$value){ $$key = $value; } $votes = $_GET['votes']; $total = ($votes + 1); $sql = mysql_query("UPDATE quotes SET votes = '$total' WHERE quoteid = '$quoteid'"); break; } I'm currently trying to break apart some PHP coding that a former coder created, but left no documentation to. Can anyone help e find the function in this mess that creates the vote button and passes the currently loaded data to the next page? Here's the original code: Code: [Select] <?php include("./templates/mysql_connect.php"); //FOR LETTER: A $query = "SELECT * FROM seniors WHERE last_name LIKE 'A%' ORDER BY last_name ASC"; $result = @mysql_query ($query); echo '<table><tr> <td> <p><span class="style19"><u>-A-</u></span><br />'; while ($row = mysql_fetch_array ($result)){ echo "<a href=\"$row[pic_url]\" rel=\"lightbox[seniors]\" title=\" <form action ="/sencha-tallyvote.php?sen_id=$row[sen_id]" method="post"> $row[first_name] $row[last_name] - $row[school] <br /> <input name="submit" align="right" type="submit" value="Vote" > </form> \">$row[last_name], $row[first_name]</a><br/>"; } echo '</p>'; ?> The original code used a lightbox feature with an added voting button tagged on near the bottom. We've Xed the lightbox feature and are trying to deconstruct it into tangible PHP pages. We have everything done except for the coding for the vote button. Here's our coding for the currently deconstructed page, and where the coding for the button needs to go: Code: [Select] <?php require_once('templates/mysql_connect.php'); ?> <?php $query = "SELECT * FROM seniors WHERE sen_id=$_GET[sen_id]"; $result = mysql_query ($query); $row = mysql_fetch_array ($result); ?> <div class="contents"> <h1><?php echo $row['first_name'], " ", $row['last_name']; ?></h1> <h4><?php echo $row['school']; ?></h4> </div> <?php echo '<a href="sencha.php" class="bigmenu"><img src="images/backarrow.png" alt="Back to Senior Challenge Home" class="arrowleft indexicon" /><u>Back</u></a><br />'; ?> <?php echo "<img src=\"http://www.rutholsonphoto.com" .$row['pic_url']. "\" width=\"100%\" />" ?> <br /> <br /> <a href="/">{{VOTEBUTTON}}</a> Any experienced help will be greatly appreciated. This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=333432.0 Hey. I just needed a little help with a voting system for articles I've put together in PHP. Essentially what happens is someone clicks the "Vote up" button which takes them to the "voteup.php" page. This is the "voteup.php" page where it updates the database for that given article and increments the "votes" column by one. This works perfectly. But the problem is people can do this infinite times and give articles infinite votes. I need it so that each IP address can only vote on each specific article once. Any ideas on how this could be done? Voteup.php Code: [Select] <?php include("connect.php"); $id2 = $_GET['id']; // Get the ID of the article that will be voted up $con = mysql_connect("localhost","lconditn_admin","hello"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("lconditn_database", $con); mysql_query("UPDATE base SET votes = votes+1 // Add one vote to the article WHERE id2 = '$id2'"); mysql_close($con); ?> Thanks a lot for any help with this. Hi, I'm currently using a voting script, but have a problem with people voting more then once, and want to add a way to keep the voting unique and 1 per person via IP check can anybody assist me how to implement it in the following script please?
<?php // the questions and the answers $pool_question="Do you think I should keep Galaxy Universe open?"; $pool_option[1]="Yes"; $pool_option[2]="No"; // If counter files are not available,they will be created // You may remove next lines after the first use of the script if (!file_exists("pool_5483543_1.txt")){ // next two lines will not work if writing permissions are not available // you may create the files bellow manualy with "0" as their unique content file_put_contents ("pool_5483543_1.txt",0); file_put_contents ("pool_5483543_2.txt",0); } // retrieve data saved in files $pool_responses[1]=file_get_contents("pool_5483543_1.txt"); $pool_responses[2]=file_get_contents("pool_5483543_2.txt"); // if user votes, increase corresponding value if ($_POST["5483543"] and $_POST["5483543b"]==""){ if ($_POST["5483543"]==1) {$pool_responses[1]++;file_put_contents("pool_5483543_1.txt",$pool_responses[1]);} if ($_POST["5483543"]==2) {$pool_responses[2]++;file_put_contents("pool_5483543_2.txt",$pool_responses[2]);} } // get percentajes for each answer in the pool // get total number of answers $total_responses=$pool_responses[1]+$pool_responses[2]; if ($total_responses==0){$total_responses=1;} // to avoid errors at start // compute percentajes (with one decimal number) $pool_percentaje[1] = round((100*$pool_responses[1])/$total_responses,1); $pool_percentaje[2] = round((100*$pool_responses[2])/$total_responses,1); // print the form, which includes de answers and the percentajes print "<center>\n"; print "<form method=post action=".$_SERVER["PHP_SELF"].">\n"; print "<b>".$pool_question."</b>\n"; print "<table cellpadding=4>\n<br>"; // answer 1 print "<tr>\n"; print "<td><input type=radio name=5483543 value=1> ".$pool_option[1]."</td>\n"; print "<td bgcolor=DDDDFF>" .$pool_responses[1]." (".$pool_percentaje[1]."%)</td>\n"; print "</tr>\n"; // answer 2 print "<tr>\n"; print "<td><input type=radio name=5483543 value=2> ".$pool_option[2]."</td>\n"; print "<td bgcolor=DDDDFF>" .$pool_responses[2]." (".$pool_percentaje[2]."%)</td>\n"; print "</tr>\n"; print "</table>\n"; // a simple control to avoid one user to vote several times if ($_POST["5483543"]){ print "<input type=hidden name=5483543b value=1>\n"; } print "<input TYPE=submit value=Add my answer>\n"; print "</form>\n"; print "</center>\n"; ?>The reason why I ask for IP check is I wan't to use $_SERVER["HTTP_X_MXIT_USERID_R"];in the place of the Ip since it give a unique name via the platform I want to implement it. Edited by cobusbo, 14 January 2015 - 01:49 PM. I am using the dragdrop functionality on a page which also updates the database.Drag and drop is working fine But i am having difficulty to determine which events to use to update the database. Here is my code
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery UI Sortable - Portlets</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css"> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script> <!--<link rel="stylesheet" href="/resources/demos/style.css">--> <style> body { min-width: 520px; } .interview-questions-column { width: 400px; float: left; padding-bottom: 100px; } .question-bank { width: 500px; float: left; padding-bottom: 100px; } .portlet { margin: 0 1em 1em 0; padding: 0.3em; } .portlet-header { padding: 0.2em 0.3em; margin-bottom: 0.5em; position: relative; } .portlet-toggle { position: absolute; top: 50%; right: 0; margin-top: -8px; } .portlet-content { padding: 0.4em; } .portlet-placeholder { border: 1px dotted black; margin: 0 1em 1em 0; height: 50px; } .sortable { border: 1px solid #eee; width: 95%; min-height: 20px; list-style-type: none; margin: 0; padding: 5px 0 0 0; float: left; margin-right: 10px; } .sortable li { margin: 0 5px 5px 5px; padding: 5px; font-size: 1.2em; width: 95%; } .bank-quertion-sotrable { border: 1px solid #eee; width: 150px; min-height: 20px; list-style-type: none; margin: 0; padding: 5px 0 0 0; float: left; margin-right: 10px; } .bank-quertion-sotrable li{ margin: 0 5px 5px 5px; padding: 5px; font-size: 1.2em; width: 200px; } .ui-state-default { height: 1.5em; line-height: 1.2em; } </style> <script> $(function() { $( ".interview-questions-column" ).sortable({ connectWith: ".interview-questions-column", handle: ".portlet-header", cancel: ".portlet-toggle", placeholder: "portlet-placeholder ui-corner-all" }); $( ".portlet" ) .addClass( "ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" ) .find( ".portlet-header" ) .addClass( "ui-widget-header ui-corner-all" ) .prepend( "<span class='ui-icon ui-icon-minusthick portlet-toggle'></span>"); $( ".portlet-toggle" ).click(function() { var icon = $( this ); icon.toggleClass( "ui-icon-minusthick ui-icon-plusthick" ); icon.closest( ".portlet" ).find( ".portlet-content" ).toggle(); }); }); $(function() { $( ".sortable" ).sortable({ placeholder: "ui-state-default", connectWith: ".connectedSortable", /*receive: function(event, ui) { // only perform for sub drop downs if($(this).hasClass('question_bank')) { // if the item doesn't have the matching sub class if (!$(this).hasClass($(ui.item).attr('class'))) { // cancel the sortable $(ui.sender).sortable('cancel'); } } alert('receive'); alert(ui.sender.attr("dataid")); alert(ui.sender.toSource()); // alert("[" + this.id + "] received [" + ui.item.attr("id") + "] from [" + ui.sender.attr("id") + "]"); },*/ update: function (event, ui) { //serial = $('#sortableF').sortable('serialize'); var data = $(this).sortable('serialize'); alert(data); //alert('update sortable'); //alert("[" + this.id + "] received [" + ui.item.attr("id") + "] from [" + ui.sender.attr("id") + "]"); // POST to server using $.post or $.ajax /*$.ajax({ data: 'test', type: 'POST', url: '/your/url/here' });*/ } }).disableSelection(); }); $(function() { $( ".draggable" ).draggable({ connectToSortable: ".sortable", helper: "clone", /*revert: function(valid) { if(valid) { alert("drop is valid"); //Dropped in a valid location } else { alert("drop is invalid"); //Dropped in an invalid location } // return !valid; return false; }*/ stop: function( event, ui ) { // alert(ui); // alert("[" + this.id + "] received [" + ui.item.attr("id") + "] from [" + ui.sender.attr("id") + "]"); } }); }); $( "ul, li" ).disableSelection(); </script> </head> <body> <div class="interview-questions-column"> <div class="portlet"> <div class="portlet-header">Feeds</div> <div class="portlet-content"> <ul id="sortableF" class="connectedSortable sortable"> <li class="ui-state-default" id="item-1">Item 1</li> <li class="ui-state-default" id="item-2">Item 2</li> <li class="ui-state-default" id="item-3">Item 3</li> <li class="ui-state-default" id="item-4">Item 4</li> <li class="ui-state-default" id="item-5">Item 5</li> </ul> </div> </div> <div class="portlet"> <div class="portlet-header">News</div> <div class="portlet-content"> <ul id="sortableS" class="connectedSortable sortable"> <li class="ui-state-default" id="item-6">Item 1</li> <li class="ui-state-default" id="item-7">Item 2</li> <li class="ui-state-default" id="item-8">Item 3</li> <li class="ui-state-default" id="item-9">Item 4</li> <li class="ui-state-default" id="item-10">Item 5</li> </ul> </div> </div> <div class="portlet"> <div class="portlet-header">Shopping</div> <div class="portlet-content"> <ul id="sortableS" class="connectedSortable sortable"> <li class="ui-state-default" id="item-11">Item 1</li> <li class="ui-state-default" id="item-12">Item 2</li> <li class="ui-state-default" id="item-13">Item 3</li> <li class="ui-state-default" id="item-14">Item 4</li> <li class="ui-state-default" id="item-15">Item 5</li> </ul> </div> </div> <div class="portlet"> <div class="portlet-header">Links</div> <div class="portlet-content"> <ul id="sortableS" class="connectedSortable sortable"> <li class="ui-state-default" id="item-16">Item 1</li> <li class="ui-state-default" id="item-17">Item 2</li> <li class="ui-state-default" id="item-18">Item 3</li> <li class="ui-state-default" id="item-19">Item 4</li> <li class="ui-state-default" id="item-20">Item 5</li> </ul> </div> </div> <div class="portlet"> <div class="portlet-header">Images</div> <div class="portlet-content"> <ul id="sortableS" class="connectedSortable sortable"> <li class="ui-state-default" id="item-21">Item 1</li> <li class="ui-state-default" id="item-22">Item 2</li> <li class="ui-state-default" id="item-23">Item 3</li> <li class="ui-state-default" id="item-24">Item 4</li> <li class="ui-state-default" id="item-25">Item 5</li> </ul> </div> </div> </div> <div class="question-bank"> <div class="portlet"> <div class="portlet-header">Question bank</div> <div class="portlet-content"> <ul id="question_back" class="connectedSortable bank-quertion-sotrable"> <li class="ui-state-default draggable" id="item-26">Item 1</li> <li class="ui-state-default draggable" id="item-27">Item 2</li> <li class="ui-state-default draggable" id="item-28">Item 3</li> <li class="ui-state-default draggable" id="item-29">Item 4</li> <li class="ui-state-default draggable" id="item-30">Item 5</li> </ul> </div> </div> </div> </body> </html>Basically above code will form few boxes with items(which are actually questions) in it. There is one box on the right side with heading "Question Bank". From the "Question Bank" we can drag the questions to other boxes but can't do the reverse(this is also working). Also we can sort the questions within the box or drag the questions from one box to another. Box heading are the categories and items are questions associated to that categories. What i need is : Event that updates the database when we drag the questions from "Question Bank" to any box on the left side. Please note Questions in the "Question Bank" are pre created coming from database. Event that updates the database when we sort the questions within the box. Event that updates the database when we drag the question from one box to another box. it should also do the sorting for that two boxes. Event that updates the database when we sort the boxes. Here is the JS Fiddle link jsfiddle.net/6o30rrzx Question Bank is comming on the bottom of the page instead of on the right side any advice and suggestions will be greatly appreciated Thank you for reading this post. Can someone tell me why the first example works, but the second example does not? Code: [Select] file_get_contents('http://pinalcountyaz.gov/Departments/Treasurer/Pages/TaxBillSearch.aspx?p=10006015E-*'); Code: [Select] $url = 'http://pinalcountyaz.gov/Departments/Treasurer/Pages/TaxBillSearch.aspx?p=10006015E-*'; file_get_contents($url); Hi heres what I would like to do, im sure its not the best way to do it but its the only way I have used in the past . getting content string <?php $file = file_get_contents('contents.txt', 'r'); echo $file; ?> usualy I would use a edit link with this code <?php if(session_is_registered(myusername)){ ?><a href="javascript:open1()"><div id="edit_link">Edit</a></div><?php } ?> But what I would like to do now is to skip the edit link and just make the content string a link once the user is logged in they will be able to click on the content string and it will activate the javascript:open1() Many thanks for your help What I am trying to do is pull the content of another page which works fine and then do echo statements. It does display the content of the page but not the echo statements. outside page Code: [Select] lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum <?php echo $stateinsert ?> lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum <?php echo $cityinsert ?> <?php echo $stateinsert ?> lorem ipsum lorem ipsum lorem ipsum lorem ipsum <?php echo $countyinsert ?> Lorum Ipsom Lorum Ipsom Lorum Ipsom </p> Code: [Select] <?php $cityinsert = "Auburn"; $stateinsert = "Alabama"; $countyinsert = "Jefferson"; $table = "auburnAL"; ?> <?php $d = file_get_contents("http://mysite.com/includes/leftcopy.php"); echo ($d); ?> It displays the lorem ipsum but won't display the echo statements. This works great but I only need part of the page for example the right column...can I do this with a class or some how. What this is is pulling information from another site. Code: [Select] <?php $g = file_get_contents("http://www.site.com/index.php"); echo ($g); ?> Hello I wanted to query something from an API, but now I have 2 times money see example below. How can I only output one of them I have already looked for a solution but cannot find any or I am looking wrong { "result": [ { "Money": 45674569.88764 }, { "Money": 546.6544356456 } ], "test": 0 } <?php $myData = file_get_contents(""); $myObject = json_decode($myData); $myObjectMap = $myObject->result; ?> <?php foreach($myObjectMap as $key => $item): ?> <?PHP echo $item->Money; ?>
Okay, so I'm trying to make a service to detect proxies. Heres what I need to know.. This is how I have it set up: 1. I have a file on mysite.com/check.php 2. My clients create a page to load my check.php file on THEIR website using file_get_contents(); Like: file_get_contents("http://mysite.com/check.php?ip=$_SERVER['REMOTE_ADDR']"); 3. My system checks for a proxy using HTTP vars, how would I get them?? Like.. if I echo $_SERVER['REMOTE_ADDR']; out on the page on MY end, it will echo the servers IP to check is using step #2 with file_get_contents(); Can anyone please help me? I am willing to pay a little, if needed :/ Thanks in advance! I coded this, it has over 600 lines... Im not sure if I should post all of it so I will. When using a account that does not exist it gives an "failed to open stream Error". Code: [Select] <?php $user = "S U O M I"; $user1 = "Tezz"; if(isset($_GET['user'])) { if(!empty($_GET['user'])) { $user = $_GET['user']; } } if(isset($_GET['user1'])) { if(!empty($_GET['user1'])) { $user1 = $_GET['user1']; } } //Skill Grabs $order = array("Overall", "Attack", "Defence", "Strength", "Hitpoints", "Ranged", "Prayer", "Magic", "Cooking", "Woodcutting", "Fletching", "Fishing", "Firemaking", "Crafting", "Smithing", "Mining", "Herblore", "Agility", "Thieving", "Slayer", "Farming", "Runecraft", "Hunter", "Construction", "Summoning", "Dungeoneering"); $get = file_get_contents("http://hiscore.runescape.com/index_lite.ws?player=$user"); $get = explode("\n", $get); $i = 0; foreach ($order as $key => $value) { $value = strtolower($value); $temp = explode(",", $get[$i]); $temp = array("rank" => $temp[0], "level" => $temp[1], "exp" => $temp[2]); $stats[$value] = $temp; $eval = "\$$value = array(\$temp[\"rank\"], \$temp[\"level\"], \$temp[\"exp\"]);"; eval($eval); $i++; } //End Skill Grabs $order1 = array("Overall1", "Attack1", "Defence1", "Strength1", "Hitpoints1", "Ranged1", "Prayer1", "Magic1", "Cooking1", "Woodcutting1", "Fletching1", "Fishing1", "Firemaking1", "Crafting1", "Smithing1", "Mining1", "Herblore1", "Agility1", "Thieving1", "Slayer1", "Farming1", "Runecraft1", "Hunter1", "Construction1", "Summoning1", "Dungeoneering1"); $get1 = file_get_contents("http://hiscore.runescape.com/index_lite.ws?player=$user1"); $get1 = explode("\n", $get1); $i1 = 0; foreach ($order1 as $key1 => $value1) { $value1 = strtolower($value1); $temp1 = explode(",", $get1[$i1]); $temp1 = array("rank1" => $temp1[0], "level1" => $temp1[1], "exp1" => $temp1[2]); $stats1[$value1] = $temp1; $eval1 = "\$$value1 = array(\$temp1[\"rank1\"], \$temp1[\"level1\"], \$temp1[\"exp1\"]);"; eval($eval1); $i1++; } //End Skill Grabs echo "<table border='1' cellpadding='5'>"; echo "<tr>"; echo "<td colspan='4'><b><center>".strtoupper($user)."</center></b></td>"; echo "<td></td>"; echo "<td colspan='4'><b><center>".strtoupper($user1)."</center></b></td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Skills</b></td>"; echo "<td><b>Rank</b></td>"; echo "<td><b>Level</b></td>"; echo "<td><b>XP</b></td>"; echo "<td></td>"; echo "<td><b>Skills</b></td>"; echo "<td><b>Rank</b></td>"; echo "<td><b>Level</b></td>"; echo "<td><b>XP</b></td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Overall</b></td>"; echo "<td>";if($overall[0]<=-1){echo "Not Ranked";}else{echo $overall[0];} echo "</td>"; echo "<td>".$overall[1]."</td>"; echo "<td>".$overall[2]."</td>"; echo "<td>"; if ($overall[2] == $overall1[2]){ echo "<img src='images/equal.png' />"; } elseif ($overall[2] <= $overall1[2]){ echo "<img src='images/downArrow.png' />"; } elseif ($overall[2] >= $overall1[2]){ echo "<img src='images/upArrow.png' />"; } echo "</td>"; echo "<td><b>Overall</b></td>"; echo "<td>";if($overall1[0]<=-1){echo "Not Ranked";}else{echo $overall1[0];} echo "</td>"; echo "<td>".$overall1[1]."</td>"; echo "<td>".$overall1[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Attack</b></td>"; echo "<td>";if($attack[0]<=-1){echo "Not Ranked";}else{echo $attack[0];} echo "</td>"; echo "<td>".$attack[1]."</td>"; echo "<td>".$attack[2]."</td>"; echo "<td>"; if ($attack[2] == $attack1[2]){ echo "<img src='images/equal.png' />"; } elseif ($attack[2] <= $attack1[2]){ echo "<img src='images/downArrow.png' />"; } elseif ($attack[2] >= $attack1[2]){ echo "<img src='images/upArrow.png' />"; } echo "</td>"; echo "<td><b>Attack</b></td>"; echo "<td>";if($attack1[0]<=-1){echo "Not Ranked";}else{echo $attack1[0];} echo "</td>"; echo "<td>".$attack1[1]."</td>"; echo "<td>".$attack1[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Defence</b></td>"; echo "<td>";if($defence[0]<=-1){echo "Not Ranked";}else{echo $defence[0];} echo "</td>"; echo "<td>".$defence[1]."</td>"; echo "<td>".$defence[2]."</td>"; echo "<td>"; if ($defence[2] == $defence1[2]){ echo "<img src='images/equal.png' />"; } elseif ($defence[2] <= $defence1[2]){ echo "<img src='images/downArrow.png' />"; } elseif ($defence[2] >= $defence1[2]){ echo "<img src='images/upArrow.png' />"; } echo "</td>"; echo "<td><b>Defence</b></td>"; echo "<td>";if($defence1[0]<=-1){echo "Not Ranked";}else{echo $defence1[0];} echo "</td>"; echo "<td>".$defence1[1]."</td>"; echo "<td>".$defence1[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Strength</b></td>"; echo "<td>";if($strength[0]<=-1){echo "Not Ranked";}else{echo $strength[0];} echo "</td>"; echo "<td>".$strength[1]."</td>"; echo "<td>".$strength[2]."</td>"; echo "<td>"; if ($strength[2] == $strength1[2]){ echo "<img src='images/equal.png' />"; } elseif ($strength[2] <= $strength1[2]){ echo "<img src='images/downArrow.png' />"; } elseif ($strength[2] >= $strength1[2]){ echo "<img src='images/upArrow.png' />"; } echo "</td>"; echo "<td><b>Strength</b></td>"; echo "<td>";if($strength1[0]<=-1){echo "Not Ranked";}else{echo $strength1[0];} echo "</td>"; echo "<td>".$strength1[1]."</td>"; echo "<td>".$strength1[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Constitution</b></td>"; echo "<td>";if($hitpoints[0]<=-1){echo "Not Ranked";}else{echo $hitpoints[0];} echo "</td>"; echo "<td>".$hitpoints[1]."</td>"; echo "<td>".$hitpoints[2]."</td>"; echo "<td>"; if ($hitpoints[2] == $hitpoints1[2]){ echo "<img src='images/equal.png' />"; } elseif ($hitpoints[2] <= $hitpoints1[2]){ echo "<img src='images/downArrow.png' />"; } elseif ($hitpoints[2] >= $hitpoints1[2]){ echo "<img src='images/upArrow.png' />"; } echo "</td>"; echo "<td><b>Constitution</b></td>"; echo "<td>";if($hitpoints1[0]<=-1){echo "Not Ranked";}else{echo $hitpoints1[0];} echo "</td>"; echo "<td>".$hitpoints1[1]."</td>"; echo "<td>".$hitpoints1[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Ranged</b></td>"; echo "<td>";if($ranged[0]<=-1){echo "Not Ranked";}else{echo $ranged[0];} echo "</td>"; echo "<td>".$ranged[1]."</td>"; echo "<td>".$ranged[2]."</td>"; echo "<td>"; if ($ranged[2] == $ranged1[2]){ echo "<img src='images/equal.png' />"; } elseif ($ranged[2] <= $ranged1[2]){ echo "<img src='images/downArrow.png' />"; } elseif ($ranged[2] >= $ranged1[2]){ echo "<img src='images/upArrow.png' />"; } echo "</td>"; echo "<td><b>Ranged</b></td>"; echo "<td>";if($ranged1[0]<=-1){echo "Not Ranked";}else{echo $ranged1[0];} echo "</td>"; echo "<td>".$ranged1[1]."</td>"; echo "<td>".$ranged1[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Prayer</b></td>"; echo "<td>";if($prayer[0]<=-1){echo "Not Ranked";}else{echo $prayer[0];} echo "</td>"; echo "<td>".$prayer[1]."</td>"; echo "<td>".$prayer[2]."</td>"; echo "<td>"; if ($prayer[2] == $prayer1[2]){ echo "<img src='images/equal.png' />"; } elseif ($prayer[2] <= $prayer1[2]){ echo "<img src='images/downArrow.png' />"; } elseif ($prayer[2] >= $prayer1[2]){ echo "<img src='images/upArrow.png' />"; } echo "</td>"; echo "<td><b>Prayer</b></td>"; echo "<td>";if($prayer1[0]<=-1){echo "Not Ranked";}else{echo $prayer1[0];} echo "</td>"; echo "<td>".$prayer1[1]."</td>"; echo "<td>".$prayer1[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Magic</b></td>"; echo "<td>";if($magic[0]<=-1){echo "Not Ranked";}else{echo $magic[0];} echo "</td>"; echo "<td>".$magic[1]."</td>"; echo "<td>".$magic[2]."</td>"; echo "<td>"; if ($magic[2] == $magic1[2]){ echo "<img src='images/equal.png' />"; } elseif ($magic[2] <= $magic1[2]){ echo "<img src='images/downArrow.png' />"; } elseif ($magic[2] >= $magic1[2]){ echo "<img src='images/upArrow.png' />"; } echo "</td>"; echo "<td><b>Magic</b></td>"; echo "<td>";if($magic1[0]<=-1){echo "Not Ranked";}else{echo $magic1[0];} echo "</td>"; echo "<td>".$magic1[1]."</td>"; echo "<td>".$magic1[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Cooking</b></td>"; echo "<td>";if($cooking[0]<=-1){echo "Not Ranked";}else{echo $cooking[0];} echo "</td>"; echo "<td>".$cooking[1]."</td>"; echo "<td>".$cooking[2]."</td>"; echo "<td>"; if ($cooking[2] == $cooking1[2]){ echo "<img src='images/equal.png' />"; } elseif ($cooking[2] <= $cooking1[2]){ echo "<img src='images/downArrow.png' />"; } elseif ($cooking[2] >= $cooking1[2]){ echo "<img src='images/upArrow.png' />"; } echo "</td>"; echo "<td><b>Cooking</b></td>"; echo "<td>";if($cooking1[0]<=-1){echo "Not Ranked";}else{echo $cooking1[0];} echo "</td>"; echo "<td>".$cooking1[1]."</td>"; echo "<td>".$cooking1[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Woodcutting</b></td>"; echo "<td>";if($woodcutting[0]<=-1){echo "Not Ranked";}else{echo $woodcutting[0];} echo "</td>"; echo "<td>".$woodcutting[1]."</td>"; echo "<td>".$woodcutting[2]."</td>"; echo "<td>"; if ($woodcutting[2] == $woodcutting1[2]){ echo "<img src='images/equal.png' />"; } elseif ($woodcutting[2] <= $woodcutting1[2]){ echo "<img src='images/downArrow.png' />"; } elseif ($woodcutting[2] >= $woodcutting1[2]){ echo "<img src='images/upArrow.png' />"; } echo "</td>"; echo "<td><b>Woodcutting</b></td>"; echo "<td>";if($woodcutting1[0]<=-1){echo "Not Ranked";}else{echo $woodcutting1[0];} echo "</td>"; echo "<td>".$woodcutting1[1]."</td>"; echo "<td>".$woodcutting1[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Fletching</b></td>"; echo "<td>".$fletching[0]."</td>"; echo "<td>".$fletching[1]."</td>"; echo "<td>".$fletching[2]."</td>"; echo "<td>"; if ($fletching[2] == $fletching1[2]){ echo "<img src='images/equal.png' />"; } elseif ($fletching[2] <= $fletching1[2]){ echo "<img src='images/downArrow.png' />"; } elseif ($fletching[2] >= $fletching1[2]){ echo "<img src='images/upArrow.png' />"; } echo "</td>"; echo "<td><b>Fletching</b></td>"; echo "<td>";if($fletching1[0]<=-1){echo "Not Ranked";}else{echo $fletching1[0];} echo "</td>"; echo "<td>".$fletching1[1]."</td>"; echo "<td>".$fletching1[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Fishing</b></td>"; echo "<td>";if($fishing[0]<=-1){echo "Not Ranked";}else{echo $fishing[0];} echo "</td>"; echo "<td>".$fishing[1]."</td>"; echo "<td>".$fishing[2]."</td>"; echo "<td>"; if ($fishing[2] == $fishing1[2]){ echo "<img src='images/equal.png' />"; } elseif ($fishing[2] <= $fishing1[2]){ echo "<img src='images/downArrow.png' />"; } elseif ($fishing[2] >= $fishing1[2]){ echo "<img src='images/upArrow.png' />"; } echo "</td>"; echo "<td><b>Fishing</b></td>"; echo "<td>";if($fishing1[0]<=-1){echo "Not Ranked";}else{echo $fishing1[0];} echo "</td>"; echo "<td>".$fishing1[1]."</td>"; echo "<td>".$fishing1[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Firemaking</b></td>"; echo "<td>";if($firemaking[0]<=-1){echo "Not Ranked";}else{echo $firemaking[0];} echo "</td>"; echo "<td>".$firemaking[1]."</td>"; echo "<td>".$firemaking[2]."</td>"; echo "<td>"; if ($firemaking[2] == $firemaking1[2]){ echo "<img src='images/equal.png' />"; } elseif ($firemaking[2] <= $firemaking1[2]){ echo "<img src='images/downArrow.png' />"; } elseif ($firemaking[2] >= $firemaking1[2]){ echo "<img src='images/upArrow.png' />"; } echo "</td>"; echo "<td><b>Firemaking</b></td>"; echo "<td>";if($firemaking1[0]<=-1){echo "Not Ranked";}else{echo $firemaking1[0];} echo "</td>"; echo "<td>".$firemaking1[1]."</td>"; echo "<td>".$firemaking1[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Crafting</b></td>"; echo "<td>";if($crafting[0]<=-1){echo "Not Ranked";}else{echo $crafting[0];} echo "</td>"; echo "<td>".$crafting[1]."</td>"; echo "<td>".$crafting[2]."</td>"; echo "<td>"; if ($crafting[2] == $crafting1[2]){ echo "<img src='images/equal.png' />"; } elseif ($crafting[2] <= $crafting1[2]){ echo "<img src='images/downArrow.png' />"; } elseif ($crafting[2] >= $crafting1[2]){ echo "<img src='images/upArrow.png' />"; } echo "</td>"; echo "<td><b>Crafting</b></td>"; echo "<td>";if($crafting1[0]<=-1){echo "Not Ranked";}else{echo $crafting1[0];} echo "</td>";; echo "<td>".$crafting1[1]."</td>"; echo "<td>".$crafting1[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Smithing</b></td>"; echo "<td>";if($smithing[0]<=-1){echo "Not Ranked";}else{echo $smithing[0];} echo "</td>"; echo "<td>".$smithing[1]."</td>"; echo "<td>".$smithing[2]."</td>"; echo "<td>"; if ($smithing[2] == $smithing1[2]){ echo "<img src='images/equal.png' />"; } elseif ($smithing[2] <= $smithing1[2]){ echo "<img src='images/downArrow.png' />"; } elseif ($smithing[2] >= $smithing1[2]){ echo "<img src='images/upArrow.png' />"; } echo "</td>"; echo "<td><b>Smithing</b></td>"; echo "<td>";if($smithing1[0]<=-1){echo "Not Ranked";}else{echo $smithing1[0];} echo "</td>"; echo "<td>".$smithing1[1]."</td>"; echo "<td>".$smithing1[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Mining</b></td>"; echo "<td>";if($mining[0]<=-1){echo "Not Ranked";}else{echo $mining[0];} echo "</td>"; echo "<td>".$mining[1]."</td>"; echo "<td>".$mining[2]."</td>"; echo "<td>"; if ($mining[2] == $mining1[2]){ echo "<img src='images/equal.png' />"; } elseif ($mining[2] <= $mining1[2]){ echo "<img src='images/downArrow.png' />"; } elseif ($mining[2] >= $mining1[2]){ echo "<img src='images/upArrow.png' />"; } echo "</td>"; echo "<td><b>Mining</b></td>"; echo "<td>";if($mining1[0]<=-1){echo "Not Ranked";}else{echo $mining1[0];} echo "</td>"; echo "<td>".$mining1[1]."</td>"; echo "<td>".$mining1[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Herblore</b></td>"; echo "<td>";if($herblore[0]<=-1){echo "Not Ranked";}else{echo $herblore[0];} echo "</td>"; echo "<td>".$herblore[1]."</td>"; echo "<td>".$herblore[2]."</td>"; echo "<td>"; if ($herblore[2] == $herblore1[2]){ echo "<img src='images/equal.png' />"; } elseif ($herblore[2] <= $herblore1[2]){ echo "<img src='images/downArrow.png' />"; } elseif ($herblore[2] >= $herblore1[2]){ echo "<img src='images/upArrow.png' />"; } echo "</td>"; echo "<td><b>Herblore</b></td>"; echo "<td>";if($herblore1[0]<=-1){echo "Not Ranked";}else{echo $herblore1[0];} echo "</td>"; echo "<td>".$herblore1[1]."</td>"; echo "<td>".$herblore1[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Agility</b></td>"; echo "<td>";if($agility[0]<=-1){echo "Not Ranked";}else{echo $agility[0];} echo "</td>"; echo "<td>".$agility[1]."</td>"; echo "<td>".$agility[2]."</td>"; echo "<td>"; if ($agility[2] == $agility1[2]){ echo "<img src='images/equal.png' />"; } elseif ($agility[2] <= $agility1[2]){ echo "<img src='images/downArrow.png' />"; } elseif ($agility[2] >= $agility1[2]){ echo "<img src='images/upArrow.png' />"; } echo "</td>"; echo "<td><b>Agility</b></td>"; echo "<td>";if($agility1[0]<=-1){echo "Not Ranked";}else{echo $agility1[0];} echo "</td>"; echo "<td>".$agility1[1]."</td>"; echo "<td>".$agility1[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Thieving</b></td>"; echo "<td>";if($thieving[0]<=-1){echo "Not Ranked";}else{echo $thieving[0];} echo "</td>"; echo "<td>".$thieving[1]."</td>"; echo "<td>".$thieving[2]."</td>"; echo "<td>"; if ($thieving[2] == $thieving1[2]){ echo "<img src='images/equal.png' />"; } elseif ($thieving[2] <= $thieving1[2]){ echo "<img src='images/downArrow.png' />"; } elseif ($thieving[2] >= $thieving1[2]){ echo "<img src='images/upArrow.png' />"; } echo "</td>"; echo "<td><b>Thieving</b></td>"; echo "<td>";if($thieving1[0]<=-1){echo "Not Ranked";}else{echo $thieving[0];} echo "</td>"; echo "<td>".$thieving1[1]."</td>"; echo "<td>".$thieving1[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Slayer</b></td>"; echo "<td>";if($slayer[0]<=-1){echo "Not Ranked";}else{echo $slayer[0];} echo "</td>"; echo "<td>".$slayer[1]."</td>"; echo "<td>".$slayer[2]."</td>"; echo "<td>"; if ($slayer[2] == $slayer1[2]){ echo "<img src='images/equal.png' />"; } elseif ($slayer[2] <= $slayer1[2]){ echo "<img src='images/downArrow.png' />"; } elseif ($slayer[2] >= $slayer1[2]){ echo "<img src='images/upArrow.png' />"; } echo "</td>"; echo "<td><b>Slayer</b></td>"; echo "<td>";if($slayer1[0]<=-1){echo "Not Ranked";}else{echo $slayer1[0];} echo "</td>"; echo "<td>".$slayer1[1]."</td>"; echo "<td>".$slayer1[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Farming</b></td>"; echo "<td>";if($farming[0]<=-1){echo "Not Ranked";}else{echo $farming[0];} echo "</td>"; echo "<td>".$farming[1]."</td>"; echo "<td>".$farming[2]."</td>"; echo "<td>"; if ($farming[2] == $farming1[2]){ echo "<img src='images/equal.png' />"; } elseif ($farming[2] <= $farming1[2]){ echo "<img src='images/downArrow.png' />"; } elseif ($farming[2] >= $farming1[2]){ echo "<img src='images/upArrow.png' />"; } echo "</td>"; echo "<td><b>Farming</b></td>"; echo "<td>";if($farming1[0]<=-1){echo "Not Ranked";}else{echo $farming[0];} echo "</td>"; echo "<td>".$farming1[1]."</td>"; echo "<td>".$farming1[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Runecrafting</b></td>"; echo "<td>";if($runecraft[0]<=-1){echo "Not Ranked";}else{echo $runecraft[0];} echo "</td>"; echo "<td>".$runecraft[1]."</td>"; echo "<td>".$runecraft[2]."</td>"; echo "<td>"; if ($runecraft[2] == $runecraft1[2]){ echo "<img src='images/equal.png' />"; } elseif ($runecraft[2] <= $runecraft1[2]){ echo "<img src='images/downArrow.png' />"; } elseif ($runecraft[2] >= $runecraft1[2]){ echo "<img src='images/upArrow.png' />"; } echo "</td>"; echo "<td><b>Runecrafting</b></td>"; echo "<td>";if($runecraft1[0]<=-1){echo "Not Ranked";}else{echo $runecraft1[0];} echo "</td>"; echo "<td>".$runecraft1[1]."</td>"; echo "<td>".$runecraft1[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Hunter</b></td>"; echo "<td>";if($hunter[0]<=-1){echo "Not Ranked";}else{echo $hunter[0];} echo "</td>"; echo "<td>".$hunter[1]."</td>"; echo "<td>".$hunter[2]."</td>"; echo "<td>"; if ($hunter[2] == $hunter1[2]){ echo "<img src='images/equal.png' />"; } elseif ($hunter[2] <= $hunter1[2]){ echo "<img src='images/downArrow.png' />"; } elseif ($hunter[2] >= $hunter1[2]){ echo "<img src='images/upArrow.png' />"; } echo "</td>"; echo "<td><b>Hunter</b></td>"; echo "<td>";if($hunter1[0]<=-1){echo "Not Ranked";}else{echo $hunter1[0];} echo "</td>"; echo "<td>".$hunter1[1]."</td>"; echo "<td>".$hunter1[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Construction</b></td>"; echo "<td>";if($construction[0]<=-1){echo "Not Ranked";}else{echo $construction[0];} echo "</td>"; echo "<td>".$construction[1]."</td>"; echo "<td>".$construction[2]."</td>"; echo "<td>"; if ($construction[2] == $construction1[2]){ echo "<img src='images/equal.png' />"; } elseif ($construction[2] <= $construction1[2]){ echo "<img src='images/downArrow.png' />"; } elseif ($construction[2] .= $construction1[2]){ echo "<img src='images/upArrow.png' />"; } echo "</td>"; echo "<td><b>Construction</b></td>"; echo "<td>";if($construction1[0]<=-1){echo "Not Ranked";}else{echo $construction1[0];} echo "</td>"; echo "<td>".$construction1[1]."</td>"; echo "<td>".$construction1[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Summoning</b></td>"; echo "<td>";if($summoning[0]<=-1){echo "Not Ranked";}else{echo $summoning[0];} echo "</td>"; echo "<td>".$summoning[1]."</td>"; echo "<td>".$summoning[2]."</td>"; echo "<td>"; if ($summoning[2] == $summoning1[2]){ echo "<img src='images/equal.png' />"; } elseif ($summoning[2] <= $summoning1[2]){ echo "<img src='images/downArrow.png' />"; } elseif ($summoning[2] >= $summoning1[2]){ echo "<img src='images/upArrow.png' />"; } echo "</td>"; echo "<td><b>Summoning</b></td>"; echo "<td>";if($summoning1[0]<=-1){echo "Not Ranked";}else{echo $summoning[0];} echo "</td>"; echo "<td>".$summoning1[1]."</td>"; echo "<td>".$summoning1[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Dungeoneering</b></td>"; echo "<td>";if($dungeoneering[0]<=-1){echo "Not Ranked";}else{echo $dungeoneering[0];} echo "</td>"; echo "<td>".$dungeoneering[1]."</td>"; echo "<td>".$dungeoneering[2]."</td>"; echo "<td>"; if ($dungeoneering[2] == $dungeoneering1[2]){ echo "<img src='images/equal.png' />"; } elseif ($dungeoneering[2] <= $dungeoneering1[2]){ echo "<img src='images/downArrow.png' />"; } elseif ($dungeoneering[2] >= $dungeoneering1[2]){ echo "<img src='images/upArrow.png' />"; } echo "</td>"; echo "<td><b>Dungeoneering</b></td>"; echo "<td>";if($dungeoneering1[0]<=-1){echo "Not Ranked";}else{echo $dungeoneering1[0];} echo "</td>"; echo "<td>".$dungeoneering1[1]."</td>"; echo "<td>".$dungeoneering1[2]."</td>"; echo "</tr>"; echo "</table>"; ?> How would I go about fixing this error? <?php $1 = file_get_contents(""); $2 = json_decode($1); $3 = $2->result; var_dump($myData1); foreach($3 as $key => $item): echo $item->Users->UserObject->UserName; endforeach; ?> { "result": [ { "ID": 1, "Users": [ { "UserObject": { "UserName": "test1" }, "...": 2 }, { "UserObject": { "UserName": "test2" }, "...": 2 } ], "IsActive": true } ], "error": false }
I get this error Notice: Trying to get property 'UserObject' of non-object in C:\xampp\htdocs\dashboard-master\chart.php on line 10 im trying to display the contents of a file within a div. plain html is fine but i need this file to have php variables within it. eg: the file tos.php <?php $foo = 'bar'; ?> <p></php echo $foo; ?></p> the code to display it: file_get_contents(tos.php); but this func only displays the html and doesnt print the contents of anything between php tags. any ideas? |