Jump to content

livewirerules

Members
  • Posts

    45
  • Joined

  • Last visited

Everything posted by livewirerules

  1. I have a feed that contains over 10000 vehicles and is about 300 mb and trying to grab and display the name and the price of each vehicle.The problem is it displays all the data in the feed. Below is the feed that i used <vehicle> <type>Double Cab </type> <price>19.5k</price> <model>GTX</model> <descrip>sdsadasdasdsa</descrip> </vehicle> <vehicle> <type>Cruise </type> <price>78k</price> <model>Ultra</model> <descrip>sdsadasdasdsa</descrip> </vehicle> <vehicle> <type>Jeep/ Wagon </type> <price>2k</price> <model>Body Kit</model> <descrip>sdsadasdasdsa</descrip> </vehicle> I’m using the below code. $url = 'vcfeed.php'; $xname ="test"; $xPassword ="testuser"; $post_data = array("username" => $xname, "password" => $xPassword"); $ch = curl_init($url); $c[CURLOPT_POST] = true; $c[CURLOPT_POSTFIELDS] = $post_data; foreach($c as $k=>$v){$c[$k] = $v;} curl_setopt_array($ch,$c); $xml = curl_exec($ch); curl_close($ch); $z = new XMLReader; $z->open($xml); $doc = new DOMDocument; while ($z->read() && $z->name !== 'vehicle'); while ($z->name === 'vehicle') { $node = simplexml_import_dom($doc->importNode($z->expand(), true)); echo $node->model; echo $node->price; $z->next('vehicle'); } Although i have used echo $node->model; echo $node->price; It doesn’t show those 2 values for each result. Can someone tell me what am i doing wrong here?
  2. It is a list of phone numbers stored in a new line 578854745 578854845 578854945 578854545 578857545
  3. Hi Im trying to load telephone numbers from a csv file and work around the array key values. But when when i try all the key values seems to be Zero. I tried to sort and assing new array key values but still its the same. Below is the code if (($open=fopen("phone.csv","r"))!== FALSE) { while (($data=fgetcsv($open))!==FALSE) { foreach ($data as $key =>$numbr){ /// working code logic echo $key."<br>"; } }} the output is as below 0 0 0 0 0 0 0 can someone please tell me how to assign the keys.
  4. $count=0; $numb=50; foreach ($sepkeys as $dbkey) { for ($page=10;$page<=$numb;$page=$page + 10) { // the if block $count=$count+1; } } I am trying to maintain a separate a count for each key number in the above code. Eg: key- 574, it searches from pages 10-50 and increments the count by 1. The problem that I have is the count is continuous. After searching for the first key and moves on to the next key and them I need the count to start from the beginning rather than being continuous. Eg: key-874 : count = 22, in my case the next key 875 : the count is 23 I need to make it 1. I removed the if block and several lines because the code is too long. Can someone please suggest me a way how to do it
  5. Figured it out using an array.. works fine now
  6. when i echo the variable $name out side the loop it says "Notice: Undefined variable name" and when i echo it inside the loop it works fine
  7. How do i use the values withing a while loop out side the loop? eg: $sql="select *from custwhere account='".$number."'"; $result=mysql_query($sql) or die(mysql_error()); while ($row=mysql_fetch_array($result)) { $name=$row['username']; $email=$row['email']; } I want to use the variables $name and $email outside the loop.. Ho wdo i do it?
  8. sorry... actually its a partial code.The complete code within the loop was about 200 lines,i just edited for a few lines. there are no syntax errors
  9. Im am trying to retrieve all the transaction information that is done by user. Below is my code $sql="select * from trans where tfid='987456'"; $result=mysql_query($sql) or die(mysql_error()); while ($row=mysql_fetch_array($result)) { $date=$row['h_date']; $ref=$row['ref']; price=$row['price']; echo"<tr> <td>$date</td> <td>$ref</td> <td>$price</td> </tr>"; I have around 6 transactions with the same tfid. but in the above code it shows only the first result.. how do i show all the 6 transactions? thanks
  10. how do i return a value from a loop within a function? function deprecated() { $sql="select * from table where id=1"; $result=mysql_query($sql) or die(mysql_error()); while ($row=mysql_fetch_array($result)) { $date=$row['date']; $cat=$row['cat']; } } i want to return both $date and $cat.... How do i do it?
  11. Can anyone tell how to Disable Maximum execution time in PHP? although i have set it to 3000 seconds it still stops at 60 seconds? Any help how to disable the time limit?
  12. Im tring to pass 2 variables to a function that uses Curl through a loop. testfunction($id,$page) curl_setopt($ch, CURLOPT_URL, "testserver.com/index.php?id=$id&page=$page"); The problem is that the result works only the first time. When i pass $id=5 and $page 5 it works fine. But when its incremented by the loop where $id=10 and $page =6. Nothing seems to be displayed. Can anyone please tell me when i am doing wrong??
  13. I need to match text that contain forward slashes /hello /test /MyWorks For eg: i want to match "/hello"? any help will be appreciated
  14. Not only google.. all the sites i try to load gives me the same error..
  15. When i try to load a url thru $dom->loadHTMLFile($url); i get the below error Warning: DOMDocument::loadHTMLFile() [domdocument.loadhtmlfile]: I/O warning : failed to load external entity any reason why??
  16. Im trying to remove an element from an array, but the problem is that although that it removes the value and adds it again into the array.. if (isset($_POST['remove'])) { $ele=$_GET['id']; //id passed from the form $key1=array_search($ele,$_SESSION['id']); echo $key1; unset($_SESSION['id'][$key1]); } can some one tell me what i am doing wrong?
  17. how do i use the return values of a function to html tags.Below is my function function nfo($id) { $feed=simplexml_load_file("feed.xml"); if (!$feed) { trigger_error("There was an error",E_USER_ERROR); } $feedx[]=array( 'centrename'=>$feed->TNFO->NAME, 'l1'=>$feed->TNFO->LOCATION->L1, 'l2'=>$feed->TNFO->LOCATION->L2, 'code'=>$feed->TNFO->LOCATION->CODE ); return $feedx; } i want to use the returned values in the below table in the location marked as XXXX. <body> <?php nfo('257');?> <table width="200" border="1"> <tr> <td>XXXX</td> <td>XXXX</td> </tr> <tr> <td>XXXX</td> <td>XXXX</td> </tr> </table> </body> is it possible to return the values into the table without using the html tags in to the function? Any help will be much appreciated Thanks.
  18. i just cant understand why i am getting that error and only one result is shown
  19. Im trying to get some values from the below xml feed <?xml version="1.0" ?> <SEARCH> <LOCATION> <NAME>Terrance</NAME> <COUNTRY>USA</COUNTRY> </LOCATION> <FOUND> <TOTALOFOUND> <TOTAL>3</TOTAL> </TOTALOFOUND> <PLACE> <ADDRESS>IL Road</ADDRESS> <NAME>shop1</NAME> <POSTCODE>5</POSTCODE> <CATIM> <SMALL>ILR.jpg</SMALL> <MEDIUM>ILR1.jpg</MEDIUM> <DESCRIPTION>feeds</DESCRIPTION> </CATIM> <BUILD>this is the first test xml feed</BUILD> <ID>1235</ID> <DIST> <LAT>25</LAT> <LONG>547</LONG> </DIST> </PLACE> <PLACE> <ADDRESS>Peter Road</ADDRESS> <NAME>textas</NAME> <POSTCODE>987</POSTCODE> <CATIM> <SMALL>test.jpg</SMALL> <MEDIUM>test1.jpg</MEDIUM> <DESCRIPTION>feeds new</DESCRIPTION> </CATIM> <BUILD>this is the second test xml feed</BUILD> <ID>1235</ID> <DIST> <LAT>25</LAT> <LONG>547</LONG> </DIST> </PLACE> <PLACE> <ADDRESS>Thsi is the 3rd st</ADDRESS> <NAME>utah</NAME> <POSTCODE>9117</POSTCODE> <CATIM> <SMALL>utah.jpg</SMALL> <MEDIUM>utah1.jpg</MEDIUM> <DESCRIPTION>feeds new 3</DESCRIPTION> </CATIM> <BUILD>this is the third test xml feed</BUILD> <ID>000000</ID> <DIST> <LAT>000</LAT> <LONG>54000</LONG> </DIST> </PLACE> </FOUND> </SEARCH> I have used the following code to grab the values <?php $strings = file_get_contents("feed.xml"); $xml=simplexml_load_string($strings); foreach ($xml as $place) { echo "Total : ".$place->TOTALOFOUND->TOTAL."<br />"; echo "address: ".$place->PLACE->ADDRESS."<br />"; echo "Name : ".$place->PLACE->NAME."<br />"; echo "post code: ".$place->PLACE->POSTCODE."<br />"; echo "Small image: ".$place->PLACE->CATIM->SMALL."<br />"; echo "Medium Image: ".$place->PLACE->CATIM->MEDIUM."<br />"; echo "Descripton: ".$place->PLACE->CATIM->DESCRIPTION."<br />"; echo "Office ID: ".$place->PLACE->ID."<br />"; echo "Cord Lat: ".$place->PLACE->DIST->LAT."<br />"; echo "Cord Long: ".$place->PLACE->DIST->LONG."<br />"."<br />"; } ?> the problem is that although i have 3 records in the xml it shows only the first results. and at the beginning it gives the below error. Can some one please help me Total : address: Name : post code: Notice: Trying to get property of non-object in C:\wamp\www\site\test.php on line 16 Small image: Notice: Trying to get property of non-object in C:\wamp\www\site\test.php on line 17 Medium Image: Descripton: Office ID: Notice: Trying to get property of non-object in C:\wamp\www\site\test.php on line 20 Cord Lat: Notice: Trying to get property of non-object in C:\wamp\www\site\test.php on line 21 Cord Long: Total : 3 address: IL Road Name : shop1 post code: 5 Small image: ILR.jpg Medium Image: ILR1.jpg Descripton: Office ID: 1235 Cord Lat: 25 Cord Long: 547 any help will be much appreciated thanks
  20. is it possible to display each result of an if statement as soon as a its executed without waiting until the complete code is executed? Eg: <? if ($submit) { if ($key) { $result = "http://localhost/act.php?x=$ebK&t=911"; //echo $result; }else { $result = "http://localhost/actF.php?x=$ebK&t=911"; } $page = file_get_contents($result); if (preg_match("$url", $page)) { echo "True"; } else { echo "false"; } if ($key) { $result = "http://localhost/act.php?x=$ebK&t=912"; //echo $result; }else { $result = "http://localhost/actF.php?x=$ebK&t=912"; } $page = file_get_contents($result); if (preg_match("$url", $page)) { echo "True"; } else { echo "false"; } } ?> the above code is repeated until t= 920 and it takes quite along time until its completed executed and display the results. is it possible to display the TRUE or FALSE as the code is executed for each IF statement? Thanks
  21. is it possible to set a execution time in php? I have a if / else statement with some conditions. I want to execute one condition and the other after about 15 seconds, so on.... is it possible? if yes can someone please explain. Thanks
  22. i have written a code that will grab the content from the index page.. i would like to know how can i leech completely thru the site (index,contact, news pages) and grab specific content only like Numbers and specific words
×
×
  • 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.