Jump to content

A bit of PHP help


acoole

Recommended Posts

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

<?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);

?>

Link to comment
Share on other sites

@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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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.