Jump to content

tejama

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Contact Methods

  • MSN
    mariotee@hotmail.com

Profile Information

  • Gender
    Not Telling
  • Location
    Canada

tejama's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Awesome! I wasn't 100% sure how to handle whitespace in reg exs, so I figured that was part of the issue. Thanks a bunch for the help!
  2. I'm trying to write code to scrape the content of a weather page to get today's forecast using preg_match_all. Below is the code I'm using that is generating the error: function get_weather() { $html = file_get_contents("http://weatheroffice.gc.ca/city/pages/nl-24_metric_e.html"); preg_match_all("/<dt>Today<\/dt><dd>(.*)<\/dd>/sm", $html, $forecast, PREG_SET_ORDER); echo $forecast[0][0]; } The piece of html content I'm trying to scrape is as follows: <dt>Today</dt> <dd>Freezing rain mixed with ice pellets changing to rain and ending near noon then cloudy. Wind becoming northeast 30 km/h gusting to 50 this morning then southwest 50 gusting to 70 near noon. High plus 4.</dd> Basically the error I'm getting is that preg_match_all is returning no results. Can anyone point out where I might be going wrong in my regex? Thanks in advance
  3. Folks, I just wanted to pass along some Friday afternoon thanks to the whole team. This site is AMAZING! I've only posted a half dozen questions or so, but rarely have I had to wait more than 10 minutes for a proper solution. Anyways, keep up the great work! Tejama
  4. Thanks, for the string I submitted that actually returns the proper value. However, I did leave something out. That is that the string I'm trying to parse has characters after 16 as well: Ortiz</a></td><td>90</td><td>330</td><td>61</td><td>106</td><td>32</td><td>0</td><td>16</td><td>18</td><td>20</td> So basically, I'm looking for a regex that will parse this line to return the value between the seventh set of <td>.
  5. I need an example of a regex that will find the name 'Ortiz' and parse it so that it returns on the last number on this line (which is 16). Ortiz</a></td><td>90</td><td>330</td><td>61</td><td>106</td><td>32</td><td>0</td><td>16</td> Appreciate any help you can give me! Thanks, Tejama
  6. Actually, I just tested it on another site running on my localhost and it worked fine. Must be the network I'm on. Thanks for the help!
  7. Hi folks, Wondering if you can give me a hand. Here's part of my code: $theurl = 'http://scores.espn.go.com/mlb/Statistics/Team/playerstats?team=det'; $contents = file_get_contents($theurl); All I'm trying to do is open the page so that I can parse the info I want later. Here is the error I get: Note: I'm running this on localhost, but I don't believe that should make a difference. Any help is appreciated.
  8. Ahhh...right you are Little Guy. Thanks for the help. SycoSyco - made a typo and forgot to include the quotes...they were in my source code though.
  9. Hey all, I'm trying to insert a date/time into Mysql. I'm entering a future date in a text box similar to '2007-12-31 6:00:00' and the field in Mysql I'm trying to insert it into is of the type datetime. I'm trying $date = $_POST['date']; $newdate = date(Y-m-d H:i:s, strtotime($date); Then I try to insert $newdate but no joy. Can anyone suggest what's going wrong here?
  10. Thanks to all who helped. I looked at using 'limit', but didn't have much success. Substr however did the job and I achieved what I was hoping for. PHPFreaks is 4 for 4!
  11. So far phpfreaks is 3 for 3 on solving my problems, so here we go again, hopefully its 4 for 4. I want to pull some info from a mysql DB and what I'm looking to do is to display only a snippet of text from a text field (ie: the first 30 words of the text entry). Can anyone suggest how I might go about doing this? Thanks in advance.
  12. Nope, what fixed it was changing the date declaration from: $startdate = date("F d, Y", strtotime($tempdate)); to: $startdate = date("Y-m-d H:i:s", strtotime($tempdate)); for both $startdate and $enddate.
  13. Thanks Skali...got it just before I read your post!
  14. I actually figured it out, here is the code I used: function archive($month) { $tempdate = $month. " 1, 2007"; $startdate = date("Y-m-d H:i:s", strtotime($tempdate)); $tempdate2 = $month. " 11, 2007"; $enddate = date("Y-m-d H:i:s", strtotime($tempdate2)); db_connect(); $result = mysql_query("select * from blog where entered >= '$startdate' and entered <= '$enddate'"); $num_rows = mysql_num_rows($result); } Thanks for the help though!
  15. Hi everyone, I'm trying to extract data in a certain range of date (say 1 month's worth), but my results aren't what I'm expecting. Can you guys have a look at my code and suggest what may not be coded properly? function display_archive($month) { $tempdate = $month. " 1, 2007"; $startdate = date("F d, Y", strtotime($tempdate)); $tempdate2 = $month. " 30, 2007"; $enddate = date("F d, Y", strtotime($tempdate2)); db_connect(); $result = mysql_query("select * from blog where entered BETWEEN '$date' and '$enddate'"); $num_rows = mysql_num_rows($result); }
×
×
  • 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.