Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 31

Thread: Export Data to CSV (Using PHP)

  1. #21
    Join Date
    Aug 2005
    Posts
    174
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    hey, i cant seem to get it working
    I dont get any error messages, just a blank page..

    PHP Code:
    <?php 
    ob_start
    (); 
    include (
    "http://www.mobiles4everyone.com/_exporths.asp"); 
    $inc ob_get_contents(); 
    ob_end_clean(); 
    $s = array(); preg_match('/<body\b[^>]*>(.*?)<\/body>/'$inc$s); $inc str_replace(" | ""|"str_replace("            """$inc)); $inc $s[1];
    echo (
    "$inc");?>

  2. #22
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Call preg_match() after the str_replace() calls.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #23
    Join Date
    Aug 2005
    Posts
    174
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    nope, still get a blank page!!

    PHP Code:
    <?php 
    ob_start
    (); 
    include (
    "http://www.mobiles4everyone.com/_exporths.asp"); 
    $inc ob_get_contents(); 
    ob_end_clean(); 
    $s = array(); 
    $inc str_replace(" | ""|"str_replace("            """$inc)); 
    preg_match('/<body\b[^>]*>(.*?)<\/body>/'$inc$s); 
    $inc $s[1];
    echo (
    "$inc");?>

  4. #24
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Try
    Code:
    $inc = $s[0];
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #25
    Join Date
    Aug 2005
    Posts
    174
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    nope!! still gettin a blank page..

  6. #26
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey
    Try
    Code:
    $inc = $s[0];
    That would show the substring that the pattern matched, not the parenthesised expression.

    The problem here is that, by default, the dot (.) pattern token doesn't match line terminators. As one exists just after the opening body tag, the match halts pretty quickly. The 's' flag will include these line terminators.

    More luck can be had with:

    Code:
    $data = file_get_contents('http://www.mobiles4everyone.com/_exporths.asp');
    $data = str_replace(' | ', '|', $data);
    
    if (preg_match('/<body\b[^>]*>\s*(.*?)\s*<\/body>/s', $data, $content)) {
      echo $content[1];
    }
    Notice that leading and trailing white space will be excluded from the capturing parentheses, so one of the str_replace function calls can be removed.

    Mike

  7. #27
    Join Date
    Aug 2005
    Posts
    174
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    your a genious!! lol, works great! thanks to everyone, twey, mike..

  8. #28
    Join Date
    Aug 2005
    Posts
    174
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    hey!

    does anyone know why this script doesnt work with php 5.2.1?
    PHP has just been updated on my host, and none of my databases are being updated!!! grr!!

    Anyone got any ideas? help is much appreciated!

  9. #29
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    What's the error?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  10. #30
    Join Date
    Aug 2005
    Posts
    174
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    there is no error..
    just get a blank page!
    if i remove the preg_match part, the script works, but all the html tags are not removed..

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •