Jump to content

t_machine

Members
  • Posts

    104
  • Joined

  • Last visited

    Never

Posts posted by t_machine

  1. Hi, I am using the following function to get the actual days between two given dates but it is having memory allocation issues.

     

     

    
    $sStartDate = 2009-06-22;
    $sEndDate = 2009-06-29;
    
    function _GetDays($sStartDate, $sEndDate){
      $sStartDate = gmdate("Y-m-d", strtotime($sStartDate));
      $sEndDate = gmdate("Y-m-d", strtotime($sEndDate));
      $aDays[] = $sStartDate;
      $sCurrentDate = $sStartDate;
      
      while($sCurrentDate < $sEndDate){
    	// Add a day to the current date
    	$sCurrentDate = gmdate("Y-m-d", strtotime("+1 day", strtotime($sCurrentDate)));
    
    	// Add this new day to the aDays array
    	$aDays[] = $sCurrentDate;
      }
      return $aDays;
    }//EOF

     

    What I am trying to do is get it to display 2009-06-22, ..23, ..24, 25, 26, 27, 28 and the 2009-06-29. This would be the days in between the start and end date  including both dates.

     

    Any help or a better code would be really appreciated.

     

    Thanks :)

     

     

  2. Hi, I have links from a database that contains the image name and type. How can i strip the name and file type from the link.

     

    Example:

    $string = 'http://mysite.com/images/myimage.png';
    

     

    How can I parse that string and get myimage.png

     

    Note also that the file type is not always .png, it is also .jpg, .jpeg, .gif....

     

    Thanks

  3. This is a weird one and I am not sure where to begin. My website is on a subdomain (http://subdomain.mysite.com)

    The problem i get is that my images and some files will not load. I checked the properties and they are linked correctly. If I visit the webpage at http://www.mysite.com/subdomain then it loads fine or if I link to the image from the browser address bar http://subdomain.mysite.com/public/images/blue.jpg then it also loads fine.

    It just will not load inside a <img src.... .

    I used firebug for firefox and found out that it is throwing a no permission error. I checked folder permission and it is fine.

    Any help would be greatly appreciated.

  4. Hi, I have a table in mysql database that stores download_file, download_date(DATETIME), user_id

    How can i get the files downloaded in the last 7 days?

     

    I am using the following but does not seem to work.

    $sql = 'SELECT download_file FROM {my_table} WHERE DATE_FORMAT(download_date, "%d%m%y") >= DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 7 DAY), "%d%m%y")';

  5. hi, i am writing a script that will give users a few options to post to another server depending on their server setup. So far I have cUrl and fsocket, I know php 5 offers HTTP, does any know how to use that to post to another server?

    I have tested on a server that has both curl and fsocket disable so I am hoping the HTTP in php 5 will help or if there is any other that would be great.

     

    Thanks for any help/guidance :)

  6. Sorry for not posting the exact codes in the first place :(

    My host will not update to php 5 and I would like a fix until I get a new host. The fix that Crayon Violent added still did not get any results.

     

    This is how the links are laid out on the page:

    <a class="CLASS_NAME" href="URL" alt="ALT_TEXT">
    <h2 class="ANOTHER_CLASS" style="display: inline;">LINK NAME</h2>
    <br/>
    </a>

     

    I am using file get content which gets the content fine but parsing it still gives no result. I am using the following with Crayon fix included

     

     $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*><h2[^>]*>(.*)<\/h2><\/a>"; 
    if(preg_match_all("/$regexp/siU", $input, $matches)) {
         foreach($matches as $match) {
           echo $match[2];
           echo $match[3];
    
         }
    }

     

    Thanks again for any help :)

  7. Thanks very much for the reply. You are right, the site does have poor coding. That may be the reason the codes you both posted did not work. Below is the exact way their links are in the page. I am not sure if them placing the class before the href makes a difference in the preg match

     

    <a class="CLASS_NAME" href="URL" alt="ALT_TEXT">
    <h2 class="ANOTHER_CLASS" style="display: inline;">LINK NAME</h2>
    <br/>
    </a>

     

    Thanks again for the help.

  8. Hi, I am trying to parse a page that contain many links. There are links on there with <h2> tags which are the ones I need. How can I get only those links?

    I am using the following but it returns every link.

     

    $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>"; 

     

    The <h2> links on the page are like the following:

    <a href="link to page"><h2>LINK NAME</h2></a>

     

    Thanks for any help :)

  9. Hi, I am trying to parse a page that contain many links. There are links on there with <h2> tags which are the ones I need. How can I get only those links?

    I am using the following but it returns every link.

     

    $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>"; 

     

    The <h2> links on the page are like the following:

    <a href="link to page"><h2>LINK NAME</h2></a>

     

    Thanks for any help :)

  10. hi, I hope someone can help with this problem.

     

    I am trying to search a table and only display results if search does not exist in another table.

    For example.

    Search table 1 for users with the name "test", get the id for that user then check Table 2 if that user id exists. If it does not exist then show results. I assume a good join would work or a sub query but I do not know where to begin.

     

    Any help would be greatly appreciated.

  11. Hi, I am wondering if anyone could help with this.

    I have a string that has both text and images but i would like to remove the first image only.

     

    Example:

    $string = 'This is my test <img src="link_to_image1" border="0">, some other text.<img src="link_to_another_image" border="0">';

     

    How can I use preg_replace to remove <img src="link_to_image1" border="0">

     

    Thanks for any help.

  12. Hi, I have a table that stores each record with in a DATETIME column. I was wondering how accurate is it to order by the date column

     

    Example

    $sql = "SELECT * FROM table_name WHERE {get todays result} ORDER BY date_column DESC";

     

    Would an order like that display the results for the day correctly, and would it list the last result for the day first?

     

    Thanks for any help :)

×
×
  • 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.