SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Dec 2006
    0 Post(s)
    0 Thread(s)

    Help inserting data into mysl

    Hi Guys,

    i have this piece of code below working great when echoed out displays the files like it should, they can be upto 100 lines depending, what i wanted to do is store ALL the date for "$output" & "$parts" in mysql but it only stores the first line not the rest, if i put my insert query in the foreach it inserts the files but makes an entry for each file (instead of the whole lot in the 1 field)

    PHP Code:
         // Before the insertion get some details...
    $filecontent file_get_contents("nzbs/$renamed_nzb");
    $parts explode("</file>",$filecontent);
    $parts as $part){
    ## get the newsgroup
    if (eregi ('subject="(.*)">'$part$matches)) {
    $titel $matches[1];
    $titel explode('">'$titel);
    '<font face=Verdana size=1>'.$titel[0]."");
                if (
    eregi("<group>(.*)</group>"$part$matches)) {
    $ng $matches[1];
    $ng str_replace("alt.binaries""a.b"$ng);
    //echo ("<font face=Verdana size=1>".$ng."");            
                ## get the poster 
    if (eregi ("poster=\"(.*)\" date="$part$matches)) {
    $poster $matches[1];
    //print("<font face=Verdana size=1>".$poster."");
                if (
    eregi ("<segment bytes=\"(.*)\" number="$part$matches)) {
    $size $matches[1];
    $size round($size 1024,2);
    $parts doe_iets($titel[0]);
    $parts str_replace("/"""$parts);
    $parts str_replace(")"""$parts);
    $output $parts $size;
    "$output kb $parts";
    $total_output $output;
    is there a way i can store the whole lot in mysql as 1 long string then ill be able to explode it and display later.

    thanks for any help guys


  2. #2
    SitePoint Evangelist
    Join Date
    Jun 2004
    0 Post(s)
    0 Thread(s)
    Why don't you just implode() it into one string, store that string, and then re explode() it? I don't see what the problem is.

    By the way, why do you use eregi? preg regex functions are much faster than ereg and have many other benefits. I recommend you just change those to preg methods
    Happy switcher to OS X running on a MacBook Pro.

    Zend Certified Engineer


Posting Permissions

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