t4newman Posted March 29, 2010 Share Posted March 29, 2010 Help! This is doing my head in - the following writes the correct config file data to a text file but I need the variable encapsulated in quotes for it to work. $Data = '$htURL = ' . $serverpath . "\r\n"; fwrite($Handle, $Data); Running out of time and lose the will on this one.... Quote Link to comment https://forums.phpfreaks.com/topic/196891-help-with-quotes-in-fwrite-command/ Share on other sites More sharing options...
aeroswat Posted March 29, 2010 Share Posted March 29, 2010 Help! This is doing my head in - the following writes the correct config file data to a text file but I need the variable encapsulated in quotes for it to work. $Data = '$htURL = ' . $serverpath . "\r\n"; fwrite($Handle, $Data); Running out of time and lose the will on this one.... You didn't ask a question Quote Link to comment https://forums.phpfreaks.com/topic/196891-help-with-quotes-in-fwrite-command/#findComment-1033712 Share on other sites More sharing options...
t4newman Posted March 29, 2010 Author Share Posted March 29, 2010 "I need the variable encapsulated in quotes for it to work." I found the right format through trial and error:- $Data = '$htURL = ' . "'" . $serverpath . "';\r\n"; However, it appears that I can't write a text file to the web server/host due to permission restrictions. I've ran out of time on the assignment I'm doing so will just explain the documentation to my tutor how you change the config text file manually. Quote Link to comment https://forums.phpfreaks.com/topic/196891-help-with-quotes-in-fwrite-command/#findComment-1033734 Share on other sites More sharing options...
aeroswat Posted March 29, 2010 Share Posted March 29, 2010 "I need the variable encapsulated in quotes for it to work." I found the right format through trial and error:- $Data = '$htURL = ' . "'" . $serverpath . "';\r\n"; However, it appears that I can't write a text file to the web server/host due to permission restrictions. I've ran out of time on the assignment I'm doing so will just explain the documentation to my tutor how you change the config text file manually. 1) That's not a question still... 2) Assuming you mean "How do I encapsulate the variable in quotes" There is no mention of what variable. There are 4 variables in the code you presented. Quote Link to comment https://forums.phpfreaks.com/topic/196891-help-with-quotes-in-fwrite-command/#findComment-1033803 Share on other sites More sharing options...
t4newman Posted March 30, 2010 Author Share Posted March 30, 2010 Sorry, you are quite correct. The last of the two variables needed to be 'variable" so that the text file would look like this:- $myvar1 = 'varvalue1'; $myvar2 = 'varvalue2';a $myvar3 = 'varvalue3'; I sorted it in the end but have had to abandon it due to the permission problem - no time left for this part. Quote Link to comment https://forums.phpfreaks.com/topic/196891-help-with-quotes-in-fwrite-command/#findComment-1033982 Share on other sites More sharing options...
oni-kun Posted March 30, 2010 Share Posted March 30, 2010 Single quotes will write the dollar symbol without needing for escaping. You can do this as well: $content = "Some content." $variable = "\$variable = $content" And as for your permissions, it's as simple as opening up your FTP client and CHMODding the file/folder to 755/777 permissions to be able to write to the folder. Quote Link to comment https://forums.phpfreaks.com/topic/196891-help-with-quotes-in-fwrite-command/#findComment-1033987 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.