Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Since Upgrade to PHP 5.6 new data Rows will inserted multiple instead of once

Status
Not open for further replies.

masterappi

Programmer
Feb 1, 2011
1
CH
Hi there

We have a problem
In our old environment (PHP5.1, 5.3 with MySQL) we do have used this code
Always the new player was oinserted if not exist once
Now this code hase two issues we not have seen before :
1.) The player was inserted - but the tips will be NOT saved
2.) The player is inserte as many times as it has an entry in the file (up to three times - which is maximum)

Code:
while (!feof($fd)) {
    $zeile=fgetss($fd,4096);
    if (strstr($zeile,"back to top")) {
        $land=split("(ft | :)",$zeile);
    } else {
        if (strstr($zeile,"|")) {
            $i++;
            preg_match($tipPattern, $zeile, $m);

            $rpos = $m[1] == '---' ? '' : $m[1];
            $rname = trim($m[2]);
            $rnat = $land[1];
            if ($m[5] == 'Keine Auswahl') {
                $rgeg = '';
            } else {
                $tmp = explode('gegen ', $m[5]);
                if (count($tmp) > 0) {
                    $rgeg = $tmp[1];
                } else {
                    $rgeg = $m[5];
                }
            }
            $rspiel = $m[4];
            $rtip = $m[3];
            $rspielt = 0;

            $nat_id = $teams[$rnat];
            $geg_id = $teams[$rgeg];

            if (isset ($players[$rname])) {
                $player_id = $players[$rname];
            } else {
                $s = "INSERT INTO tm_nm_players (player_name) VALUES ('$rname')";
                mysqli_query ($db_connection,$s);
                $player_id = mysqli_insert_id ();
                $players[$rname] = $player_id;
            }

All other rows will be read and insert with (directly next line in code) :

Code:
             $sql="INSERT INTO tm_nm_tips (saison,woche,player_id,team_id,vsteam_id,spiel_get,tip,pos,spielt) ";
                        $sql.="VALUES ('$saison_id','$woche_id',$player_id,'$nat_id','$geg_id','$rspiel','$rtip','$rpos','$rspielt')";
                        //print $sql;
                        mysqli_query($db_connection,$sql);
        }
    }
}
correctly. Only Players which are new will be only inserted in first table, but tipps are not stored. Next time when user is existing it will be store all Tipps correctly
What can be the difference between older PHP and 5.6 in case of this behaviour ?
thanks in advance
Uwe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top