1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to insert this data to mysql database

Discussion in 'PHP' started by kasun0777, Nov 5, 2011.

  1. #1
    I added into table. but i need to ad this data to database:(

    <?php
    $url = "http://xxx.com/xxx.php";
    
    $FileContent = file_get_contents($url);
    
    $SplitContent = explode("\n", $FileContent);
    
     
    foreach($SplitContent as $CurrValue)
    {      
      echo "<tr>";
      
      $SplitData = explode("\t", $CurrValue);
      foreach($SplitData as $DataValue){
      echo "<td>".$DataValue."</td>";
      }
      
      echo "</tr>";
    }
    
    ?>
    PHP:
     
    kasun0777, Nov 5, 2011 IP
  2. dplover147

    dplover147 Member

    Messages:
    120
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    36
    #2
    do u want to add this PHP data into database ?
     
    dplover147, Nov 5, 2011 IP
  3. kasun0777

    kasun0777 Well-Known Member

    Messages:
    355
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    138
    #3
    yes. i want that data into to the database.
     
    kasun0777, Nov 5, 2011 IP
  4. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #4
    kmap, Nov 5, 2011 IP
  5. dplover147

    dplover147 Member

    Messages:
    120
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    36
    #5
    use htmlspecialchars() function to add into database
    <?php 
    
    $txt = '
    <?php
    $url = "http://xxx.com/xxx.php";
    
    $FileContent = file_get_contents($url);
    
    $SplitContent = explode("\n", $FileContent);
    
     
    foreach($SplitContent as $CurrValue)
    {      
      echo "<tr>";
     
      $SplitData = explode("\t", $CurrValue);
      foreach($SplitData as $DataValue){
      echo "<td>".$DataValue."</td>";
      }
     
      echo "</tr>";
    }
    
    ?>
    ';
    
    
    $strin = htmlspecialchars($txt);
    
    ?>
    PHP:
     
    dplover147, Nov 5, 2011 IP
  6. kasun0777

    kasun0777 Well-Known Member

    Messages:
    355
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    138
    #6
    kasun0777, Nov 5, 2011 IP
  7. dplover147

    dplover147 Member

    Messages:
    120
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    36
    #7
    INSERT INTO table_name (column_name) VALUES ($string);
     
    dplover147, Nov 5, 2011 IP
  8. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #8
    kmap, Nov 5, 2011 IP
  9. kasun0777

    kasun0777 Well-Known Member

    Messages:
    355
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    138
    #9
    have 12 fields.
     
    kasun0777, Nov 5, 2011 IP
  10. Anveto

    Anveto Well-Known Member

    Messages:
    697
    Likes Received:
    40
    Best Answers:
    19
    Trophy Points:
    195
    #10
    <?php
    $url = "http://xxx.com/xxx.php";
    
    $FileContent = file_get_contents($url);
    
    $SplitContent = explode("\n", $FileContent);
    
     
    foreach($SplitContent as $CurrValue)
    {      
      echo "<tr>";
     
      $SplitData = explode("\t", $CurrValue);
      foreach($SplitData as $DataValue){
      echo "<td>".$DataValue."</td>";
      mysql_query("INSERT INTO table ('columnname') VALUES ('$DataValue')");
      }
     
      echo "</tr>";
    }
    
    ?>
    PHP:
     
    Anveto, Nov 6, 2011 IP