thewooleymammoth Posted December 20, 2007 Share Posted December 20, 2007 trying to just write files but its not working <?php $GT=$_POST['GT']; $GI=$_POST['GI']; $GD=$_POST['GD']; $link=$_POST['link']; $overall=$_POST['overall']; $GP=$_POST['Gameplay']; $graphics=$_POST['Graphics']; $controls=$_POST['Controls']; $RV=$_POST['RV']; $dif=$_POST['Difficulty']; $gamelist="games/list.txt"; $file=fopen($gamelist, "a"); if(fwrite($file, "$GT||")) { echo "game has been added to the list"; } else { echo "error 1"; } fclose($file); $game="games/$GT.txt"; $file=fopen($game, "w"); if(fwrite($file, "$GT||$GI||$GD||$link||$overall||$GP||$graphics||$controls||$RV||$dif||")) { echo "<br> Game info has been written"; } else { echo "error 2"; } fclose($file); ?> create the list file but instead of "||" it has the game title then "||||" and there is a third file with no name that just accumulates "||" with every entry. im stumped also can you guys suggest a good file editor for php files? Quote Link to comment https://forums.phpfreaks.com/topic/82455-solved-file-writting-problem/ Share on other sites More sharing options...
thewooleymammoth Posted December 20, 2007 Author Share Posted December 20, 2007 alright so the problem is wierder <?php include('top.html'); $GT=$_POST['GT']; $GI=$_POST['GI']; $GD=$_POST['GD']; $link=$_POST['link']; $overall=$_POST['overall']; $GP=$_POST['Gameplay']; $graphics=$_POST['Graphics']; $controls=$_POST['Controls']; $RV=$_POST['RV']; $dif=$_POST['Difficulty']; $gamelist="games/list.txt"; $file=fopen($gamelist, "a"); if(fwrite($file, "$GT"."|")) { echo "game has been added to the list"; } else { echo "error 1"; } fclose($file); $game="games/$GT.txt"; $file=fopen($game, "w"); if(fwrite($file, "$GT|$GI|$GD|$link|$overall|$GP|$graphics|$controls|$RV|$dif")) { echo "<br> Game info has been written"; } else { echo "error 2"; } fclose($file); echo "<br>$GT"; include('bottom.html'); ?> creates the files, but it adds an addition "|" with it.... and creates an extra file with no name ".txt" that has "|||||||||" after five entrys... im also trying to do the amazon affiliate program and cant figure out how to display one of the links it provides from the file the link looks like this <iframe src="http://rcm.amazon.com/e/cm?t=vghu-20&o=1&p=8&l=as1&asins=B000F5IH2I&fc1=000000&IS2=1<1=_blank&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr&nou=1" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe> Quote Link to comment https://forums.phpfreaks.com/topic/82455-solved-file-writting-problem/#findComment-419225 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.