kworld Posted September 12, 2010 Share Posted September 12, 2010 When the webpage loads it inserts all its information via xml into the database. This all works fine and perfect untill i reload the page again then it starts screwing up all the data im not sure what im doing wrong i know this isnt much info but is there a common mistake im making? Link to comment https://forums.phpfreaks.com/topic/213229-something-is-wrong-php/ Share on other sites More sharing options...
Pikachu2000 Posted September 12, 2010 Share Posted September 12, 2010 You won't likely get a relevant answer without posting relevant code. Link to comment https://forums.phpfreaks.com/topic/213229-something-is-wrong-php/#findComment-1110297 Share on other sites More sharing options...
kworld Posted September 12, 2010 Author Share Posted September 12, 2010 Heres all the code, i cant see what i'm doing wrong, it works fine at first but if i reload page it doesn't. <?php include 'connect.php'; $query = "SELECT * FROM pilot_tbl"; $results = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_assoc($results)) { $CharID = $row['CharID']; $UserID = $row['UserID']; $ApiKey = $row['ApiKey']; $CharN = $row['CharN']; $file="http://api.eve-online.com/char/FacWarStats.xml.aspx?apikey=$ApiKey&characterID=$CharID&userID=$UserID"; //$file="FacWarStats.xml.aspx.xml"; $get = file_get_contents($file); $xml = new SimpleXMLElement($get); if ($xml->result) { foreach($xml->result->currentRank as $dcrank);{ foreach($xml->result->highestRank as $dhrank);{ foreach($xml->result->killsYesterday as $dykills);{ foreach($xml->result->killsLastWeek as $dlwkills);{ foreach($xml->result->killsTotal as $dtkills);{ foreach($xml->result->victoryPointsYesterday as $dvypoints);{ foreach($xml->result->victoryPointsLastWeek as $dvlwpoints);{ foreach($xml->result->victoryPointsTotal as $dvtpoints);{ $query1 = "SELECT * FROM pstats WHERE charid='$CharID'"; $results1 = mysql_query($query1); $row1 = mysql_fetch_array($results1); if ($row1) { extract ($row1); $query2 = "UPDATE pstats SET Crank = '$dcrank', Hrank = '$dhrank', Ykills = '$dykills', LWkills = '$dlwkills', Tkills = '$dtkills', VYpoints = '$dvypoints', VLWpoints = '$dvlwpoints' ,VTpoints = '$dvtpoints'"; $insert2 = mysql_query($query2) or (mysql_error()); } if (!$row1) { $query2 = "INSERT INTO pstats (charid, CharN, Crank, Hrank, Ykills, LWkills, Tkills, VYpoints, VLWpoints, VTpoints) VALUES ( '$CharID', '$CharN', '$dcrank', '$dhrank', '$dykills', '$dlwkills', '$dtkills', '$dvypoints', '$dvlwpoints', '$dvtpoints')"; $insert2 = mysql_query($query2) or (mysql_error()); } }}}}}}}} } } ?> Link to comment https://forums.phpfreaks.com/topic/213229-something-is-wrong-php/#findComment-1110301 Share on other sites More sharing options...
Hypnos Posted September 12, 2010 Share Posted September 12, 2010 $query2 = "UPDATE pstats SET Crank = '$dcrank', Hrank = '$dhrank', Ykills = '$dykills', LWkills = '$dlwkills', Tkills = '$dtkills', VYpoints = '$dvypoints', VLWpoints = '$dvlwpoints' ,VTpoints = '$dvtpoints'"; $insert2 = mysql_query($query2) This is likely your problem. You don't have a WHERE clause so it will UPDATE everything. Link to comment https://forums.phpfreaks.com/topic/213229-something-is-wrong-php/#findComment-1110351 Share on other sites More sharing options...
kworld Posted September 13, 2010 Author Share Posted September 13, 2010 Thanks man how the fuck did i not notice that. Link to comment https://forums.phpfreaks.com/topic/213229-something-is-wrong-php/#findComment-1110441 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.