Stupid SYNTAX error...... help !!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
oxygen
Forum Newbie
Posts: 4
Joined: Tue Aug 09, 2005 5:34 pm

Stupid SYNTAX error...... help !!

Post by oxygen »

well, i got this script for a "automatic account creation" thingy for a game, and now i am getting this dam error like i didnt close a string or something

exact error:
"Parse error: syntax error, unexpected T_STRING in C:\xampplite\htdocs\xml.php on line 113"

here is the file "xml.php"

URL: http://web.telia.com/~u16118881/xml.php

please explain thuraly so a newb can understand :P or even better fix the link and repost the xml.php file :P
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Can you post line 113 +- 20 lines so we can see it in context?

My guess is that $name or $race or something has a single quote in it, which breaks your string. If you're doing big chunks like that, look into heredocs. They're pretty bulletproof.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
oxygen
Forum Newbie
Posts: 4
Joined: Tue Aug 09, 2005 5:34 pm

Post by oxygen »

ok sry, but i dont understand a <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> what ur saying.... take it in newbish language plz.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

He's saying post your code so we can see whats going wrong.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
oxygen
Forum Newbie
Posts: 4
Joined: Tue Aug 09, 2005 5:34 pm

Post by oxygen »

http://web.telia.com/~u16118881/xml.php

THERE IT IS:

Code: Select all

<?php

function zapisz(){
$account = $_POST['account'];
$password = $_POST['password'];
$name = $_POST['name'];
$race = $_POST['race'];
$sex = $_POST['sex'];
$ip = $_SERVER['REMOTE_ADDR'];

$tresc1 = '<?xml version="1.0"?>
<account pass="'.$password.'" type="1" premDays="1337">
<characters>
<character name="'.$name.'"/>
</characters>
</account>';
$plik = fopen("C:\Documents and Settings\Fam Jansson\Skrivbord\ot_survival\data\accounts/".$account.".xml","w");
fwrite($plik,$tresc1);
fclose($plik);
$plik2 = fopen("C:\Documents and Settings\Fam Jansson\Skrivbord\ot_survival\data\players/".$name.".xml","w");

if ($race == 1){
$tresc2 = '<?xml version="1.0"?>

<player name="'.$name.'" account="'.$account.'" sex="'.$sex.'" lookdir="0" exp="98800" voc="'.$race.'" level="20" maglevel="4" access="0" cap="300">
<mana now="400" max="400" spent="0"/>
<health now="200" max="200" food="0"/>
<look type="128" head="20" body="30" legs="40" feet="50"/>
<skills>
<skill skillid="0" level="30" tries="0"/>
<skill skillid="1" level="50" tries="0"/>
<skill skillid="2" level="50" tries="0"/>
<skill skillid="3" level="50" tries="0"/>
<skill skillid="4" level="10" tries="0"/>
<skill skillid="5" level="50" tries="0"/>
<skill skillid="6" level="40" tries="0"/>
</skills>
<inventory>
<slot slotid="1"><item id="1730"/></slot>
<slot slotid="2"><item id="1890"/></slot>
<slot slotid="3"><item id="1411"/></slot>
<slot slotid="4"><item id="1736"/></slot>
<slot slotid="5"><item id="1788"/></slot>
<slot slotid="6"><item id="1700"/></slot>
<slot slotid="7"><item id="1877"/></slot>
<slot slotid="8"><item id="1874"/></slot>
</inventory>
<spawn x="336" y="82" z="7"/>
</player>';

}
if ($race == 2) {
$tresc2 = '<?xml version="1.0"?>

<player name="'.$name.'" account="'.$account.'" sex="'.$sex.'" lookdir="0" exp="98800" voc="'.$race.'" level="20" maglevel="30" access="0" cap="300">
<mana now="300" max="300" spent="0"/>
<health now="300" max="300" food="0"/>
<look type="128" head="20" body="30" legs="40" feet="50"/>
<skills>
<skill skillid="0" level="10" tries="0"/>
<skill skillid="1" level="15" tries="0"/>
<skill skillid="2" level="10" tries="0"/>
<skill skillid="3" level="10" tries="0"/>
<skill skillid="4" level="10" tries="0"/>
<skill skillid="5" level="18" tries="0"/>
<skill skillid="6" level="35" tries="0"/>
</skills>
<inventory>
<slot slotid="1"><item id="1730"/></slot>
<slot slotid="2"><item id="1890"/></slot>
<slot slotid="3"><item id="1411"/></slot>
<slot slotid="4"><item id="1736"/></slot>
<slot slotid="5"><item id="1788"/></slot>
<slot slotid="6"><item id="1724"/></slot>
<slot slotid="7"><item id="1877"/></slot>
<slot slotid="8"><item id="1874"/></slot> 
</inventory>
<spawn x="336" y="82" z="7"/>
</player>';
}
if ($race == 3) {
$tresc2 = '<?xml version="1.0"?>

<player name="'.$name.'" account="'.$account.'" sex="'.$sex.'" lookdir="0" exp="98800" voc="'.$race.'" level="20" maglevel="14" access="0" cap="300">
<mana now="400" max="400" spent="0"/>
<health now="200" max="200" food="0"/>
<look type="128" head="20" body="30" legs="40" feet="50"/>
<skills>
<skill skillid="0" level="20" tries="0"/>
<skill skillid="1" level="35" tries="0"/>
<skill skillid="2" level="10" tries="0"/>
<skill skillid="3" level="10" tries="0"/>
<skill skillid="4" level="50" tries="0"/>
<skill skillid="5" level="40" tries="0"/>
<skill skillid="6" level="35" tries="0"/>
</skills>
<inventory>
<slot slotid="1"><item id="1730"/></slot>
<slot slotid="2"><item id="1890"/></slot>
<slot slotid="3"><item id="1411"/></slot>
<slot slotid="4"><item id="1736"/></slot>
<slot slotid="6"><item id="1728"/></slot>
<slot slotid="7"><item id="1877"/></slot>
<slot slotid="8"><item id="1874"/></slot>
<slot slotid="10"><item id="1800"/></slot> 
</inventory>
<spawn x="336" y="82" z="7"/>

}

fwrite($plik2,$tresc2);
fclose($plik2);
setcookie('tibia', 'true', time() + 24*3600);
echo "The Account had been made, see you on 81.225.200.209  Etunaland ";
}



function wyjdz(){
$account = $_POST['account'];
$password = $_POST['password'];
$name = $_POST['name'];
$race = $_POST['race'];
$sex = $_POST['sex'];
$dupa = 0;
$ip = $_SERVER['REMOTE_ADDR'];
$plik3 ='C:\Documents and Settings\Fam Jansson\Skrivbord\ot_survival\data\accounts/'.$account.'.xml';
$plik4 ='C:\Documents and Settings\Fam Jansson\Skrivbord\ot_survival\data\players/'.$name.'.xml';
if ($account < 100000){
   $x1 = '<font color ="red"> Your account must have at least 6 numbers !!! </font>';
   $dupa = 1;
        }
if ($_COOKIE['tibia'] == 'true'){
        $x6 = '<font color ="red"> You cannot create any new Accounts in 24h </font><br><br>';
        $dupa = 1;
}
if (file_exists($plik3)){
$x1='<font color ="red"> Account already in use</font>';
$dupa = 1;
}
if (file_exists($plik4)) {
$x3='<font color ="red"> Name already in use</font>';
$dupa = 1;
}
if ($race == 1 || $race == 2 || $race == 3){

    }
    else{
    $x4 = '<font color ="red"> Race is not valid</font>';
    $dupa = 1;
}
if ($sex == 1 || $sex == 2){
        }
        else{
    $x5 = '<font color ="red"> Sex is not valid</font>';
    $dupa = 1;
    }
$name = explode(" ",$name);
if ($name[0] == "GM" || $name[0]=="Gm" || $name[0]=="gm") {
        $x3='<font color ="red"> You cant have a GM !!</font>';
        $dupa = 1;
        }
if ($name == ""){
$x3 = '<font color ="red"> Your name cannot be empty !!</font>';
$dupa = 1;
}
if ($password == ""){
$x2 = '<font color ="red"> Your password cannot be empty !!</font>';
$dupa = 1;
}
if (is_numeric($account)){
}else
{
$x1='<font color ="red"> Account must by a number!!</font>';
}
if ($dupa == 1){
$plik = fopen("blad.php","w");
$tresc = '<html>
<head>
  <title></title>
</head>
<body>
<br>
<form action="xml.php" method="POST">
<br><br>Made by J a n s s o n <br><br>';
$tresc1='Account : <input type = "text" name = "account" maxlength="6">'.$x1.'<br><br>';
$tresc2='Password : <input type = "password" name ="password">'.$x2.'<br><br>';
$tresc3='Name : <input type = "text" name ="name">'.$x3.'<br><br>';
$tresc4='Race : <input type = "text" name ="race">(type 1 for knight; 2 for pally and 3 for sorcer)'.$x4.'<br><br>';
$tresc5='Sex : <input type = "text" name ="sex">(type 1 for male and 2 for female)'.$x5.'<br><br>';
$tresc6=$x6;
$tresc7='<input type = "Submit" value = "ADD" > <input type = "Reset" value = "Clear">
</form>
</body>

</html>';
fwrite($plik,$tresc.$tresc1.$tresc2.$tresc3.$tresc4.$tresc5.$tresc6.$tresc7);
fclose($plik);
header('Location: blad.php');
}
else{
        zapisz();
        }

}

wyjdz();
?>
JCART | Please use

Code: Select all

tags when posting php code. Review [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Code: Select all

<?php

function zapisz(){
$account = $_POST['account'];
$password = $_POST['password'];
$name = $_POST['name'];
$race = $_POST['race'];
$sex = $_POST['sex'];
$ip = $_SERVER['REMOTE_ADDR'];

$tresc1 = '<?xml version="1.0"?>
<account pass="'.$password.'" type="1" premDays="1337">
<characters>
<character name="'.$name.'"/>
</characters>
</account>';
$plik = fopen("C:\Documents and Settings\Fam Jansson\Skrivbord\ot_survival\data\accounts/".$account.".xml","w");
fwrite($plik,$tresc1);
fclose($plik);
$plik2 = fopen("C:\Documents and Settings\Fam Jansson\Skrivbord\ot_survival\data\players/".$name.".xml","w");

if ($race == 1){
$tresc2 = '<?xml version="1.0"?>

<player name="'.$name.'" account="'.$account.'" sex="'.$sex.'" lookdir="0" exp="98800" voc="'.$race.'" level="20" maglevel="4" access="0" cap="300">
<mana now="400" max="400" spent="0"/>
<health now="200" max="200" food="0"/>
<look type="128" head="20" body="30" legs="40" feet="50"/>
<skills>
<skill skillid="0" level="30" tries="0"/>
<skill skillid="1" level="50" tries="0"/>
<skill skillid="2" level="50" tries="0"/>
<skill skillid="3" level="50" tries="0"/>
<skill skillid="4" level="10" tries="0"/>
<skill skillid="5" level="50" tries="0"/>
<skill skillid="6" level="40" tries="0"/>
</skills>
<inventory>
<slot slotid="1"><item id="1730"/></slot>
<slot slotid="2"><item id="1890"/></slot>
<slot slotid="3"><item id="1411"/></slot>
<slot slotid="4"><item id="1736"/></slot>
<slot slotid="5"><item id="1788"/></slot>
<slot slotid="6"><item id="1700"/></slot>
<slot slotid="7"><item id="1877"/></slot>
<slot slotid="8"><item id="1874"/></slot>
</inventory>
<spawn x="336" y="82" z="7"/>
</player>';

}
if ($race == 2) {
$tresc2 = '<?xml version="1.0"?>

<player name="'.$name.'" account="'.$account.'" sex="'.$sex.'" lookdir="0" exp="98800" voc="'.$race.'" level="20" maglevel="30" access="0" cap="300">
<mana now="300" max="300" spent="0"/>
<health now="300" max="300" food="0"/>
<look type="128" head="20" body="30" legs="40" feet="50"/>
<skills>
<skill skillid="0" level="10" tries="0"/>
<skill skillid="1" level="15" tries="0"/>
<skill skillid="2" level="10" tries="0"/>
<skill skillid="3" level="10" tries="0"/>
<skill skillid="4" level="10" tries="0"/>
<skill skillid="5" level="18" tries="0"/>
<skill skillid="6" level="35" tries="0"/>
</skills>
<inventory>
<slot slotid="1"><item id="1730"/></slot>
<slot slotid="2"><item id="1890"/></slot>
<slot slotid="3"><item id="1411"/></slot>
<slot slotid="4"><item id="1736"/></slot>
<slot slotid="5"><item id="1788"/></slot>
<slot slotid="6"><item id="1724"/></slot>
<slot slotid="7"><item id="1877"/></slot>
<slot slotid="8"><item id="1874"/></slot>
</inventory>
<spawn x="336" y="82" z="7"/>
</player>';
}
if ($race == 3) {
$tresc2 = '<?xml version="1.0"?>

<player name="'.$name.'" account="'.$account.'" sex="'.$sex.'" lookdir="0" exp="98800" voc="'.$race.'" level="20" maglevel="14" access="0" cap="300">
<mana now="400" max="400" spent="0"/>
<health now="200" max="200" food="0"/>
<look type="128" head="20" body="30" legs="40" feet="50"/>
<skills>
<skill skillid="0" level="20" tries="0"/>
<skill skillid="1" level="35" tries="0"/>
<skill skillid="2" level="10" tries="0"/>
<skill skillid="3" level="10" tries="0"/>
<skill skillid="4" level="50" tries="0"/>
<skill skillid="5" level="40" tries="0"/>
<skill skillid="6" level="35" tries="0"/>
</skills>
<inventory>
<slot slotid="1"><item id="1730"/></slot>
<slot slotid="2"><item id="1890"/></slot>
<slot slotid="3"><item id="1411"/></slot>
<slot slotid="4"><item id="1736"/></slot>
<slot slotid="6"><item id="1728"/></slot>
<slot slotid="7"><item id="1877"/></slot>
<slot slotid="8"><item id="1874"/></slot>
<slot slotid="10"><item id="1800"/></slot>
</inventory>
<spawn x="336" y="82" z="7"/>';

}

fwrite($plik2,$tresc2);
fclose($plik2);
setcookie('tibia', 'true', time() + 24*3600);
echo "The Account had been made, see you on 81.225.200.209  Etunaland ";
}



function wyjdz(){
$account = $_POST['account'];
$password = $_POST['password'];
$name = $_POST['name'];
$race = $_POST['race'];
$sex = $_POST['sex'];
$dupa = 0;
$ip = $_SERVER['REMOTE_ADDR'];
$plik3 ='C:Documents and SettingsFam JanssonSkrivbordot_survivaldataaccounts/'.$account.'.xml';
$plik4 ='C:Documents and SettingsFam JanssonSkrivbordot_survivaldataplayers/'.$name.'.xml';
if ($account < 100000){
   $x1 = '<font color ="red"> Your account must have at least 6 numbers !!! </font>';
   $dupa = 1;
        }
if ($_COOKIE['tibia'] == 'true'){
        $x6 = '<font color ="red"> You cannot create any new Accounts in 24h </font><br><br>';
        $dupa = 1;
}
if (file_exists($plik3)){
$x1='<font color ="red"> Account already in use</font>';
$dupa = 1;
}
if (file_exists($plik4)) {
$x3='<font color ="red"> Name already in use</font>';
$dupa = 1;
}
if ($race == 1 || $race == 2 || $race == 3){

    }
    else{
    $x4 = '<font color ="red"> Race is not valid</font>';
    $dupa = 1;
}
if ($sex == 1 || $sex == 2){
        }
        else{
    $x5 = '<font color ="red"> Sex is not valid</font>';
    $dupa = 1;
    }
$name = explode(" ",$name);
if ($name[0] == "GM" || $name[0]=="Gm" || $name[0]=="gm") {
        $x3='<font color ="red"> You cant have a GM !!</font>';
        $dupa = 1;
        }
if ($name == ""){
$x3 = '<font color ="red"> Your name cannot be empty !!</font>';
$dupa = 1;
}
if ($password == ""){
$x2 = '<font color ="red"> Your password cannot be empty !!</font>';
$dupa = 1;
}
if (is_numeric($account)){
}else
{
$x1='<font color ="red"> Account must by a number!!</font>';
}
if ($dupa == 1){
$plik = fopen("blad.php","w");
$tresc = '<html>
<head>
  <title></title>
</head>
<body>
<br>
<form action="xml.php" method="POST">
<br><br>Made by J a n s s o n <br><br>';
$tresc1='Account : <input type = "text" name = "account" maxlength="6">'.$x1.'<br><br>';
$tresc2='Password : <input type = "password" name ="password">'.$x2.'<br><br>';
$tresc3='Name : <input type = "text" name ="name">'.$x3.'<br><br>';
$tresc4='Race : <input type = "text" name ="race">(type 1 for knight; 2 for pally and 3 for sorcer)'.$x4.'<br><br>';
$tresc5='Sex : <input type = "text" name ="sex">(type 1 for male and 2 for female)'.$x5.'<br><br>';
$tresc6=$x6;
$tresc7='<input type = "Submit" value = "ADD" > <input type = "Reset" value = "Clear">
</form>
</body>

</html>';
fwrite($plik,$tresc.$tresc1.$tresc2.$tresc3.$tresc4.$tresc5.$tresc6.$tresc7);
fclose($plik);
header('Location: blad.php');
}
else{
        zapisz();
        }

}

wyjdz();
?>
Missing quote :wink:
oxygen
Forum Newbie
Posts: 4
Joined: Tue Aug 09, 2005 5:34 pm

Post by oxygen »

U FIXED IT ?!
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Please stop posting in caps lock.
And why don't you try it out....
Post Reply