Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/82455-solved-file-writting-problem/
Share on other sites

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&lt1=_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>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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