PHP - File_get_contents Or Curl - Which One To Take?
A German DB that collects all the data from all German Foundations... see: http://www.suche.stiftungen.org/index.php?strg=87_124&baseID=129 Here we find all Foundations in Germany: : 8074 different foundations You get the full results if you choose % as wildcard in the Search-field. But if we do that - then you get some kind of overflow... 350 results are the limit. More is not possible to show. So the question is: How can we create a spider that runs across the site and asks step by step - that we get all : 8074 results. The way to get through this database is to search combinations of letters eg "ac" and select search only titles. Then go through every pair of letters. If you still get too many results for a particular pair, use 3 letters. aca, acb,... Can i do this with File_get_contents_ or with Curl!? (eg -MultiCurl ) Well - i want to make a little script thatdoes this - i need to create a little automation - that does this task automatically. Regarding the destination database, it's all going into sqlite, which we believe can handle large enough sets of data without any problems. We can download the database as a file too. For capabilities, see he http://www.sqlite.org/limits.html The question is _ how to create the first approach of the parser...!`? Can any body assist! Similar TutorialsAll, I'm trying to use some code to get some file contents from another website and am looking at performance. What is the quicker way and better for my resources to get out to websites, is it cURL or by using file_get_contents? Thanks in advance. Hi everyone
I've look all other the web for a work around that.
basically my problem is:
if i use file_get_contents or curl to get www.google.fr, there is NO problem. i get the data i want
but when i try to use it on another target it doesn't work. it loads and loads for couple seconds and finally says that it could not retrieve informations.
the target is not blocked as i can personnally use it on my webhost, but some people on other webhosts can't.
A friend of mine told me that it was because some webhosts blocks unsecure targets.
Is there any way around it?
$context = stream_context_create(array( 'http' => array( 'header' => "Authorization: Basic " . base64_encode("admin:$password") ) )); $data = file_get_contents("http://TARGETHOST:29015/status.json", false, $context); $status = json_decode($data); var_dump($status);(And again this works on my webhost, i can query like that any servers i want, but others can't use this they get a timeout trying it (when doing a file_get_contents on google works)) I would like to spoof the useragent as googlebot through the implementation of file_get_contents, or curl (which ever is easiest). How to do this? Googlebot useragent = Googlebot/2.1 (+http://www.google.com/bot.html) good day dear community, i am workin on a Curl loop to fetch multiple pages: i have some examples - and a question: Example: If we want to get information from 3 sites with CURL we can do it like so: $list[1] = "http://www.example1.com"; $list[2] = "ftp://example.com"; $list[3] = "http://www.example2.com"; After creating the list of links we should initialize the cURL multi handle and adding the cURL handles. $curlHandle = curl_multi_init(); for ($i = 1;$i <= 3; $i++) $curl[$i] = addHandle($curlHandle,$list[$i]); Now we should execute the cURL multi handle retrive the content from the sub handles that we added to the cURL multi handle. ExecHandle($curlHandle); for ($i = 1;$i <= 3; $i++) { $text[$i] = curl_multi_getcontent ($curl[$i]); echo $text[$i]; } In the end we should release the handles from the cURL multi handle by calling curl_multi_remove_handle and close the cURL multi handle! If we want to another Fetch of sites with cURL-Multi - since this is the most pretty way to do it! Well I am not sure bout the string concatenation. How to do it - Note I want to fetch several hundred pages: see the some details for this target-server sites - /(I have to create a loop over several hundred sites). * siteone.example/?show_subsite=9009 * siteone.example/?show_subsite=9742 * siteone.example/?show_subsite=9871 .... and so on and so forth Question: How to appy this loop into the array of the curl-multi? <?php /************************************\ * Multi interface in PHP with curl * * Requires PHP 5.0, Apache 2.0 and * * Curl * ************************************* * Writen By Cyborg 19671897 * * Bugfixed by Jeremy Ellman * \***********************************/ $urls = array( "siteone", "sitetwo", "sitethree" ); $mh = curl_multi_init(); foreach ($urls as $i => $url) { $conn[$i]=curl_init($url); curl_setopt($conn[$i],CURLOPT_RETURNTRANSFER,1);//return data as string curl_setopt($conn[$i],CURLOPT_FOLLOWLOCATION,1);//follow redirects curl_setopt($conn[$i],CURLOPT_MAXREDIRS,2);//maximum redirects curl_setopt($conn[$i],CURLOPT_CONNECTTIMEOUT,10);//timeout curl_multi_add_handle ($mh,$conn[$i]); } do { $n=curl_multi_exec($mh,$active); } while ($active); foreach ($urls as $i => $url) { $res[$i]=curl_multi_getcontent($conn[$i]); curl_multi_remove_handle($mh,$conn[$i]); curl_close($conn[$i]); } curl_multi_close($mh); print_r($res); ?> I look forward to your ideas. <?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? 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); ?> 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 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! 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; ?>
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. 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); 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? I've always used this query but it no longer works: Code: [Select] $data=file_get_contents('http://clients1.google.com/complete/search?hl=en&q='.$keyword); For more info, I posted about this here last year. Now, the query no longer works. Is there any other way to produce the results or is it just no longer going to work for me? I want to load and display the content of a text file (actually it is a cache file). I tested both method using a long for loop as Code: [Select] for ($i=0; $i < 10000; $i++) { $handle = fopen("test.txt", "r"); $text = fread($handle, filesize("test.txt")); fclose($handle); echo $text; }and Code: [Select] for ($i=0; $i < 10000; $i++) { $text = file_get_contents("test.txt"); echo $text; } but the results were similar, though with a large distribution of the comparative data. The speed of a method was 0.5 to 2.0 faster than the other one (in various runs). Which method do you recommend? Could you please quote the pros and cons of each method? Hello, is this ok to do? or should I add in some type of fail safe in case for some reason the server is down etc? If so, how? Code: [Select] public function check_update() { $query = $this->db->where('setting_name', 'version')->get('settings')->row(); $latest = file_get_contents('http://www.mydomain.com/version.txt') ) if ( version_compare($query->value, $latest, '<') ) return true; else return false; } Hi, I am trying write the contents of a php file's output, which echos out a small output of text based on variables and calulations, to a single file. I have tried fwrite and file_get_contents. When I run my code I get the file to create but the file it creates only outputs "1". Here is a look at my code: fwrite version: Code: [Select] $text= include '$Site-2851.php'; $file = fopen("myfile.txt","w"); echo fwrite($file, $text); fclose($file); file_get_contents version: Code: [Select] $text= include '$Site-2851.php'; $file = 'myfile.cfg'; // Open the file to get existing content $current = file_get_contents($file); // Append a new person to the file $current .= $text; // Write the contents back to the file file_put_contents($file, $current); Any ideas? Hey guys i am trying to extract the HTML of a loop of links. Each links are diffrent pages and i manualy cheked and there all diffrent ... but for some reason, the loop always sends back the same html ... the one from the first loop. while($i<=3){ echo file_get_contents("http://www.amazon.com/s/ref=nb_sb_noss_1/187-7591397-0314036?url=search-alias%3Dvideogames&field-keywords=ps3#/ref=sr_pg_$i?rh=n%3A468642%2Ck%3Aps3+game&page=$i&d=1&keywords=ps3+game&ie=UTF8&qid=1333219791"); echo "<hr>"; $i++; } Normaly i should get page 1 2 3 ... but i get 3 times the page 1 ... the URL is good because if i manualy open them the content is diffrent in each page How can I make it so that if file_get_contents cannot find the file else <?php $file = file_get_contents("http://www.example.com/lol.txt"); if ( $file == true ) { } else { } |