seularts Posted May 10, 2008 Share Posted May 10, 2008 this is my code: <? $keyword=$_POST["key"]; $key=$keyword.', '; $data = fopen('keywords.txt', "a"); fwrite($data,$key); fclose($data); ?> the problem is that it outputs: Keyword, , Keyword, , Keyword, I don't want double commas. Link to comment https://forums.phpfreaks.com/topic/105041-writting-data-to-file/ Share on other sites More sharing options...
Fadion Posted May 10, 2008 Share Posted May 10, 2008 It looks like ure getting: keyword, empty post, keyword, empty post... U can throw an if(isset($_POST['keyword'])) before writting the file. Link to comment https://forums.phpfreaks.com/topic/105041-writting-data-to-file/#findComment-537721 Share on other sites More sharing options...
seularts Posted May 10, 2008 Author Share Posted May 10, 2008 I think that the comma is witting itself again! Link to comment https://forums.phpfreaks.com/topic/105041-writting-data-to-file/#findComment-537723 Share on other sites More sharing options...
Fadion Posted May 10, 2008 Share Posted May 10, 2008 I used exactly the following code for a test: <form name="form1" method="post" action=""> <input name="key" type="text" id="key"> <input type="submit" name="Submit" value="Submit"> </form> <?php if(isset($_POST['key'])){ $keyword=$_POST["key"]; $key=$keyword.', '; $data = fopen('keywords.txt', "a"); fwrite($data,$key); fclose($data); } ?> I entered "guilty" and submitted, "gear" and submitted and "guiltygear" and submitted and the output in "keywords.txt" is exactly: guilty, gear, guiltygear, Cant seem to find a problem here!! Link to comment https://forums.phpfreaks.com/topic/105041-writting-data-to-file/#findComment-537732 Share on other sites More sharing options...
seularts Posted May 10, 2008 Author Share Posted May 10, 2008 Ups.. sry you are right.. thanks alot for the hint:D Link to comment https://forums.phpfreaks.com/topic/105041-writting-data-to-file/#findComment-537735 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.