Jump to content

Help with getting from txt file


ameriblog

Recommended Posts

I have the following code, trying to get content from a text file and inserting it into the database. Right now, for some reason, the code is only entering the first line from the .txt file and not the rest of the lines...

 

<?php

require ( "dbconnex.php" );

$lines = file('wv_scores.txt');
foreach ($lines as $line)
{
    $team = $score = array();
    $teamscore = explode(',', $line);
    foreach ($teamscore as $k=>$ts)
    {
        $x = strrpos($ts, ' ');
        $team[$k] = trim(substr($ts,0,$x));
        $score[$k] = trim(substr($ts,$x));
    }






$games_rs = $conn->Execute ( "INSERT INTO wvhs_gm (team1_name, team1_score, team2_name, team2_score, game_year, team1, team2, game_extra, game_extra1, game_date, game_fixed) VALUES ('$team[0]', '$score[0]', '$team[1]', '$score[1]', 2007, 0, 0, 'NA', 'NA', '" . $_GET['date'] . "', 0)" ) or die ( $conn->ErrorMsg() );



$add_rating_rs = $conn->Execute($sql) or die ( $conn->ErrorMsg() );





}
?>

Link to comment
https://forums.phpfreaks.com/topic/67912-help-with-getting-from-txt-file/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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