acoole Posted March 9, 2008 Share Posted March 9, 2008 Hey there, I get this error: Parse error: syntax error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/acoole/public_html/testing/done.php on line 11 For this script: <?php $path = "./"; // this will prevent XSS echo "<h1>Congratulations!</h1> - You're registered on "; // replace $_SESSION['username'] will the variable that holds your user name $file = fopen($path.$_POST["name"].".ini","a+"); // write contents fwrite($file,"Key=$_POST["age"]; Level=1 AdminLevel=0 DonateRank=0 UpgradePoints=0 ConnectedTime=0 Registered=1 Sex=1 Age=25 Origin=2 CK=0 Muted=0 Respect=0 Money=25900 Bank=50000 Crimes=0 Kills=0 Deaths=1 Arrested=0 WantedDeaths=0 Phonebook=0 LottoNr=0 Fishes=0 BiggestFish=0 Job=0 Paycheck=1175 HeadValue=0 Jailed=0 JailTime=0 Materials=0 Drugs=0 Leader=0 Member=0 FMember=255 Rank=0 Char=0 ContractTime=0 DetSkill=0 SexSkill=0 BoxSkill=0 LawSkill=0 MechSkill=0 JackSkill=0 CarSkill=0 NewsSkill=0 DrugsSkill=0 CookSkill=0 FishSkill=0 pSHealth=0.0 pHealth=48.0 Int=0 Local=255 Team=3 Model=264 PhoneNr=8284 House=255 Bizz=255 Pos_x=246.6 Pos_y=-1161.9 Pos_z=1029.6 CarLic=0 FlyLic=0 BoatLic=0 FishLic=0 GunLic=0 Gun1=0 Gun2=0 Gun3=0 Gun4=0 Ammo1=0 Ammo2=0 Ammo3=0 Ammo4=0 CarTime=0 PayDay=4 PayDayHad=0 CDPlayer=0 Wins=0 Loses=0 AlcoholPerk=0 DrugPerk=0 MiserPerk=0 PainPerk=0 TraderPerk=0 Tutorial=1 Mission=0 Warnings=0 Adjustable=1 Fuel=0 Married=0 MarriedTo=No-one "); // close the file fclose($file); ?> What's wrong? Please help! Thanks! Quote Link to comment Share on other sites More sharing options...
trq Posted March 9, 2008 Share Posted March 9, 2008 fwrite($file,"Key=$_POST['age']; Quote Link to comment Share on other sites More sharing options...
acoole Posted March 9, 2008 Author Share Posted March 9, 2008 Hrmm.. Can you show me what it'd look like fixed; I'm a bit of a newbie to PHP scripting. Thanks in advanced! Quote Link to comment Share on other sites More sharing options...
trq Posted March 9, 2008 Share Posted March 9, 2008 fwrite($file,"Key=$_POST['age']; Quote Link to comment Share on other sites More sharing options...
Xajel Posted March 9, 2008 Share Posted March 9, 2008 the line has something wrong // write contents fwrite($file,"Key=$_POST["age"]; Level=1 AdminLevel=0 DonateRank=0 etc... to // write contents fwrite($file,"Key=". $_POST["age"] ." Level=1 AdminLevel=0 DonateRank=0 etc.. Quote Link to comment Share on other sites More sharing options...
acoole Posted March 9, 2008 Author Share Posted March 9, 2008 That didn't work(probally because I screwed somthing up) Can you give me that fixed bit inside my current script. So basically the whole script with your fix put in; Thanks in advanced! Quote Link to comment Share on other sites More sharing options...
trq Posted March 9, 2008 Share Posted March 9, 2008 <?php $path = "./"; // this will prevent XSS echo "<h1>Congratulations!</h1> - You're registered on "; // replace $_SESSION['username'] will the variable that holds your user name $file = fopen($path.$_POST["name"].".ini","a+"); $text = "Key=" . $_POST["age"]; $text .= "Level=1 AdminLevel=0 DonateRank=0 UpgradePoints=0 ConnectedTime=0 Registered=1 Sex=1 Age=25 Origin=2 CK=0 Muted=0 Respect=0 Money=25900 Bank=50000 Crimes=0 Kills=0 Deaths=1 Arrested=0 WantedDeaths=0 Phonebook=0 LottoNr=0 Fishes=0 BiggestFish=0 Job=0 Paycheck=1175 HeadValue=0 Jailed=0 JailTime=0 Materials=0 Drugs=0 Leader=0 Member=0 FMember=255 Rank=0 Char=0 ContractTime=0 DetSkill=0 SexSkill=0 BoxSkill=0 LawSkill=0 MechSkill=0 JackSkill=0 CarSkill=0 NewsSkill=0 DrugsSkill=0 CookSkill=0 FishSkill=0 pSHealth=0.0 pHealth=48.0 Int=0 Local=255 Team=3 Model=264 PhoneNr=8284 House=255 Bizz=255 Pos_x=246.6 Pos_y=-1161.9 Pos_z=1029.6 CarLic=0 FlyLic=0 BoatLic=0 FishLic=0 GunLic=0 Gun1=0 Gun2=0 Gun3=0 Gun4=0 Ammo1=0 Ammo2=0 Ammo3=0 Ammo4=0 CarTime=0 PayDay=4 PayDayHad=0 CDPlayer=0 Wins=0 Loses=0 AlcoholPerk=0 DrugPerk=0 MiserPerk=0 PainPerk=0 TraderPerk=0 Tutorial=1 Mission=0 Warnings=0 Adjustable=1 Fuel=0 Married=0 MarriedTo=No-one "; // write contents fwrite($file,$text); // close the file fclose($file); ?> Quote Link to comment Share on other sites More sharing options...
Xajel Posted March 9, 2008 Share Posted March 9, 2008 @thorpe : this code will not have a linebreak (\n) after the first line... so he must add \n before the second line to make it work Quote Link to comment Share on other sites More sharing options...
trq Posted March 9, 2008 Share Posted March 9, 2008 @thorpe : this code will not have a linebreak (\n) after the first line... so he must add \n before the second line to make it work the op never mentioned anything about line breaks. You are assuming, I don't. Quote Link to comment Share on other sites More sharing options...
acoole Posted March 9, 2008 Author Share Posted March 9, 2008 Thanks! Just one more problem, this error when running the script Congratulations! - You're registered on Warning: fopen(/home/sfrp/sa-mp/scriptfiles/testing.ini) [function.fopen]: failed to open stream: Permission denied in /home/acoole/public_html/testing/done.php on line 8 Warning: fwrite(): supplied argument is not a valid stream resource in /home/acoole/public_html/testing/done.php on line 104 Warning: fclose(): supplied argument is not a valid stream resource in /home/acoole/public_html/testing/done.php on line 107 Quote Link to comment Share on other sites More sharing options...
Xajel Posted March 9, 2008 Share Posted March 9, 2008 you have to give 777 permission to that file in order to write/modify it use your FTP client to do this, or you may use SSH if you like @thorpe, yeh I assumed that as the text has each var in it's own line, and the code you have will put two var's in one line Quote Link to comment Share on other sites More sharing options...
acoole Posted March 9, 2008 Author Share Posted March 9, 2008 I've given it 777... Quote Link to comment 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.