just-j Posted July 24, 2006 Share Posted July 24, 2006 ok im not going to put the exact code because i dont have it here with me. but here what im trying to dofunction BLABLA($var1, $var2){echo $var1;echo $var2;}$test1 = $_POST['bla1'];$test2 = $_POST['bla2'];BLABLA($test1, $test2);thats not the exact code and not even what i want it to do.. im actually writing to a text file in the function.. but what happens is it writes $test1 $test2 to the file and not what is contained in the variable.. how do i get it to write what $test1 and $test2 is referring to instead of actually writing '$test1 $test2'?? Quote Link to comment https://forums.phpfreaks.com/topic/15449-functions-and-variables-help/ Share on other sites More sharing options...
kenrbnsn Posted July 24, 2006 Share Posted July 24, 2006 The code you've posted should work fine. Post the exact code that isn't working please.Ken Quote Link to comment https://forums.phpfreaks.com/topic/15449-functions-and-variables-help/#findComment-62657 Share on other sites More sharing options...
just-j Posted July 24, 2006 Author Share Posted July 24, 2006 booted up my creation station (laptop) here is the exact php code[code]<?phpfunction WriteTo($fileloc, $towrite) {$fo = fopen($fileloc,"a+ ");fwrite($fo, $towrite);fclose($fo);}$user = $_POST['user'];$bio = $_POST['bio'];WriteTo('testing.txt', '$user $bio'); ?>[/code]its writes $user $bio in the text file. i also tried takeing out the single quotes around $user $bio and i get an error when i do that.one more thing.. if you can help me fix this, then how would i make it break to a new line at the end when writing to the text file. instead of starting exactly where it left off? Quote Link to comment https://forums.phpfreaks.com/topic/15449-functions-and-variables-help/#findComment-62659 Share on other sites More sharing options...
spyke01 Posted July 24, 2006 Share Posted July 24, 2006 i think you can add \n or \r to the end of the $toWrite variable, i forget which one you should use Quote Link to comment https://forums.phpfreaks.com/topic/15449-functions-and-variables-help/#findComment-62683 Share on other sites More sharing options...
just-j Posted July 24, 2006 Author Share Posted July 24, 2006 ok that answers that.. but what about the other problem.. the one im more conserned about... please help Quote Link to comment https://forums.phpfreaks.com/topic/15449-functions-and-variables-help/#findComment-62689 Share on other sites More sharing options...
spyke01 Posted July 24, 2006 Share Posted July 24, 2006 what you want to do is this[code]WriteTo('testing.txt', $user . $bio);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15449-functions-and-variables-help/#findComment-62691 Share on other sites More sharing options...
just-j Posted July 24, 2006 Author Share Posted July 24, 2006 i figured it out... putting the variables in "double quotes" worked.. now that /n /r thing.. i added it but it writes a little box in the .txt file this is the code fwrite($fo, $towrite /n); what am i doing wrong.. i just want it to start a new line so when i write to the .txt file again it'll start on the new fresh line. Quote Link to comment https://forums.phpfreaks.com/topic/15449-functions-and-variables-help/#findComment-62699 Share on other sites More sharing options...
spyke01 Posted July 24, 2006 Share Posted July 24, 2006 the little box is the newline character, sometimes notepad freadks out on it, if you copy and paste it into say wordpad it will change it to a new line, try these twofwrite($fo, $towrite . "/n");fwrite($fo, $towrite . "/r");im suprised php isnt throwing errors the way your doing your variables, if you are doing anything wih multiple variables(echo, print, functions, etc) then the . is your friend. it appends one variable onto the end of the other Quote Link to comment https://forums.phpfreaks.com/topic/15449-functions-and-variables-help/#findComment-62956 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.