Jump to content

writer

Members
  • Posts

    50
  • Joined

  • Last visited

    Never

Everything posted by writer

  1. I've got this massive amount of data coming from a WSDL that produces movie theaters and times. It's for an open-source local news site that I'm going to be handing out to struggling newspapers I'm having trouble parsing this, or printing it, in the ways that I've learned so far in my nascent PHP career -- so I'd like to ask you guys: How do you print elements individual elements when the print_r($variable) command turns out like this? I wish it was like this: echo $results[0][theater]; But that produces this error: Fatal error: Cannot use object of type stdClass as array in /home/taylorwb/public_html/localmost/movies/test.php on line 9 Here's what an individual array element looks like: stdClass Object ( [Theater] => Array ( [0] => stdClass Object ( [Name] => CineArts at Palo Alto Square [Address] => 3000 El Camino Real, Bldg. #6, Palo Alto, CA [Movies] => stdClass Object ( [Movie] => Array ( [0] => stdClass Object ( [Rating] => PG-13 [Name] => Reprise [RunningTime] => 1 hr 43 mins [showTimes] => 1:30pm | 4:10pm | 7:00pm | 9:40pm ) [1] => stdClass Object ( [Name] => The Visitor [showTimes] => 2:00pm | 4:30pm | 7:10pm | 9:35pm ) ) ) )
  2. At the heart of the matter: Can I use fopen() to compare two documents?
  3. I'm using the following code to copy an XML feed locally, but I'd like it to first check the remote file to see if it's the same as the original file... if so, I don't need to copy it again. <?php $content = $_POST['content']; $file = $_POST['fileName']; $content = stripslashes($content); $writeFile = fopen($file, "w"); if(fwrite($writeFile, $content)) { echo $content; } else { echo "Error writing to file"; } fclose($writeFile); ?>
  4. When trying to use the code below, I'm getting an error. From Googling the error, I can tell that I have to write to a relative path, but I'm not familiar with fwrite() and need some help figuring out where. Error: Warning: fopen(http://www.washingtonpost.com/wp-dyn/rss/print/index.xml1210815958) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/taylorwb/public_html/aheds/WaPoScrape.php on line 7 Warning: fwrite(): supplied argument is not a valid stream resource in /home/taylorwb/public_html/aheds/WaPoScrape.php on line 8 Warning: fclose(): supplied argument is not a valid stream resource in /home/taylorwb/public_html/aheds/WaPoScrape.php on line 9 Code: <?php $path = "http://www.washingtonpost.com/wp-dyn/rss/print/index.xml"; $xml = file_get_contents($path); echo $xml; $name = substr($path, strpos("/", $path), strlen($path)); $file = fopen($name . time(), "w"); fwrite($file, $xml); fclose($file); ?>
  5. Thanks for the code! Hmm. Any way around this? Warning: fopen(http://www.dapper.net/RunDapp?dappName=TheDrudgeReportRSS&v=1&applyToUrl=http%3A%2F%2Fwww.drudgereport.com1210792822) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/taylorwb/public_html/aheds/scrape.php on line 6 Warning: fwrite(): supplied argument is not a valid stream resource in /home/taylorwb/public_html/aheds/scrape.php on line 7 Warning: fclose(): supplied argument is not a valid stream resource in /home/taylorwb/public_html/aheds/scrape.php on line 8
  6. I take it by your tone that there's a really easy way to copy an XML file?
  7. I'm wondering if there's a way to copy remote XML data using a script with a cronjob put on it. Has anyone ever seen something like this?
  8. Followup: I can figure out Tuesday (find current Tuesday and count back) ... but can anyone help me figure out how to establish the first and last day's of the month?
  9. I'd like to do something similar. It sounds like there's a lot to it.
  10. I'm having a lot of trouble wrapping my head around PHP's mktime function. I've got a a few difficult tasks (for example, pull all records filed on a Tuesday this year) and was wondering if there's a class library out there somewhere that can cut down my development time. Anyone know of an easier way to work with unix timestamps in PHP?
  11. Wow, thanks Barand! Now how would I implement this? My guess: $n = new knack ($cap, $start)
  12. i need this code to be this one , but work. That cracked me up.
  13. Not sure how you're going to solve this: To get the background color, you need to use a:active, but you can only have one link active at a time.
  14. I should be able to get an approx. answer if I can convert this to PHP: int knack(int cap, int start) { for(int i=start, max=0;i<N;i++) { int space=cap-item[i].size; if(space >= 0) { int t = knack(space, i+1)+item[i].val; if(t>max) { max=t; } } } return max; }
  15. Top two articles when I stopped by: 1. Simple but interesting 2. Long but wierd
  16. Yeah, I did a surface-level Google dive and found nothing. As soon as I found explode() I felt like an idiot. Thanks for the help.
  17. Aha! A reply! I've heard of it being done at an academic level using JS, but at the time didn't have any programming knowledge.
  18. I'd like to create a simple input form (field + submit button) that takes a comma separated list of locations (Paris, Hungary, Prague, etc.), strips the comma and turns the answers into an array ( $ar_locations = (1->Paris, 2->Hungary... etc.) ). Any idea of some resources with which I can do this?
  19. Why sorry? Sounds like a good thing to me!
  20. Vanilla does everything so well that I don't know why you're messing around with a custom build. But if you check out how they do it in their source, you might be able to figure out how to emulate it.
  21. It could be that the script can't handle the space in your image title (perhaps "Picture_043.jpg" would work). Maybe you need to echo it out in ASCII? <img src="imageresize.php?maxsize=xxx&source=images/Picture 043.jpg" border=0 />
  22. Check out predefined variables. $var = $_SERVER['DOCUMENT_ROOT'] should capture the page URL.
  23. Read up on $_GET and $_POST. They more-or-less do the same thing, and are probably what you're looking for.
×
×
  • 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.