PDA

Click to See Complete Forum and Search --> : parse error...


johnsx2002
Sep 21st, 2003, 04:41 AM
Well, i'm uploading the script to my server, and i'm getting this error when i try an access the script.

Parse error: parse error in /home/jclegg/public_html/st/addsoldier.php on line 13

my script is:

<?
//config//
$user = "usergoeshere";
$pass = "passgoeshere";
$db = "dbnamegoeshere";
//dont change anything under this//

$link = mysql_connect( "localhost", $user, $pass );
mysql_select_db( $db, $link );

if ( $action == "" ) {

</form>
<form name="form1" method="post" action="addsoldier.php?action=add">
<blockquote>
<p align="center">Real Name:
<input name="realname" type="text" id="realname">
</p>
</blockquote>
</form>
<form name="form2" method="post" action="addsoldier.php?action=add">
<blockquote>
<p align="center">Americas Army name (if you play)
<input name="americasarmyname" type="text" id="americasarmyname">
</p>
</blockquote>
</form>
<form name="form3" method="post" action="addsoldier.php?action=add">
<blockquote>
<p align="center">Military branch::
<input name="militarybranch" type="text" id="militarybranch">
</p>
</blockquote>
</form>
<form name="form4" method="post" action="addsoldier.php?action=add">
<blockquote>
<p align="center">Rank:
<input name="rank" type="text" id="rank">
</p>
</blockquote>
</form>
<form name="form5" method="post" action="addsoldier.php?action=add">
<blockquote>
<p align="center">MOS (occupation civilian terms)
<input name="mos" type="text" id="mos">
</p>
</blockquote>
</form>
<form name="form6" method="post" action="addsoldier.php?action=add">
<blockquote>
<p align="center">Based at (ship if Navy)
<input name="basedat" type="text" id="basedat">
</p>
</blockquote>
</form>
<blockquote>
<form name="form8" method="post" action="">
<div align="center">
<p>How long have you served? (or serving)
<input name="servedanserving" type="text" id="servedanserving">
</p>
<p>&nbsp; </p>
</div>
</form>
<form name="form7" method="post" action="add">
<div align="center">
<input type="submit" name="Submit" value="Submit">
</div>
</form>
<p align="center">&nbsp;</p>
</blockquote>
}

if ( $action == "add" ) {
mysql_query("INSERT into tblmil ( fdrealn,fdaan,fdmilbranch,fdrank,fdmos,fdbased,fdserving) values ( '$Information has been added' );
echo "$Information has been added";
}

mysql_close( $link );
?>


PS: and of course i have the things filled up above.

da_silvy
Sep 21st, 2003, 10:13 AM
<?
//config//
$user = "usergoeshere";
$pass = "passgoeshere";
$db = "dbnamegoeshere";
//dont change anything under this//

$link = mysql_connect( "localhost", $user, $pass );
mysql_select_db( $db, $link );

if ( $action == "" ) {
?>
</form>
<form name="form1" method="post" action="addsoldier.php?action=add">
<blockquote>
<p align="center">Real Name:
<input name="realname" type="text" id="realname">
</p>
</blockquote>
</form>
<form name="form2" method="post" action="addsoldier.php?action=add">
<blockquote>
<p align="center">Americas Army name (if you play)
<input name="americasarmyname" type="text" id="americasarmyname">
</p>
</blockquote>
</form>
<form name="form3" method="post" action="addsoldier.php?action=add">
<blockquote>
<p align="center">Military branch::
<input name="militarybranch" type="text" id="militarybranch">
</p>
</blockquote>
</form>
<form name="form4" method="post" action="addsoldier.php?action=add">
<blockquote>
<p align="center">Rank:
<input name="rank" type="text" id="rank">
</p>
</blockquote>
</form>
<form name="form5" method="post" action="addsoldier.php?action=add">
<blockquote>
<p align="center">MOS (occupation civilian terms)
<input name="mos" type="text" id="mos">
</p>
</blockquote>
</form>
<form name="form6" method="post" action="addsoldier.php?action=add">
<blockquote>
<p align="center">Based at (ship if Navy)
<input name="basedat" type="text" id="basedat">
</p>
</blockquote>
</form>
<blockquote>
<form name="form8" method="post" action="">
<div align="center">
<p>How long have you served? (or serving)
<input name="servedanserving" type="text" id="servedanserving">
</p>
<p> </p>
</div>
</form>
<form name="form7" method="post" action="add">
<div align="center">
<input type="submit" name="Submit" value="Submit">
</div>
</form>
<p align="center"> </p>
</blockquote>
<?
}

if ( $action == "add" ) {
mysql_query("INSERT into tblmil ( fdrealn,fdaan,fdmilbranch,fdrank,fdmos,fdbased,fdserving) values ( '$Information has been added' );
echo "$Information has been added";
}

mysql_close( $link );
?>

johnsx2002
Sep 21st, 2003, 11:07 AM
I keep getting parse errors on like their was one on line 82, well their was nothing on line 82.... then 81 nothin on 81 then, um...tried deletn couple things, that didn't work...

phpman
Sep 21st, 2003, 11:13 AM
that is becasue you forgot a quote on the end of this line

mysql_query("INSERT into tblmil ( fdrealn,fdaan,fdmilbranch,fdrank,fdmos,fdbased,fdserving) values ( '$Information has been added') ");

johnsx2002
Sep 21st, 2003, 11:22 AM
when i hit "Submit" it goes to a 404 page... what do I do? cuz now it shows all the stuff so i filled it out to test it, so (thank you that works now! :)) but i hit submit an it just gives me a 404!

oh an when i hit submit it doens't add the data to the db

phpman
Sep 21st, 2003, 11:38 AM
I just really looked at the code and found you have way to many form tags. you only use 1

this is where your page is going

<form name="form7" method="post" action="add">

nowhere.

try this

<?
//config//
$user = "usergoeshere";
$pass = "passgoeshere";
$db = "dbnamegoeshere";
//dont change anything under this//

$link = mysql_connect( "localhost", $user, $pass );
mysql_select_db( $db, $link );

if ( $action == "" ) {
?>

<form name="form1" method="post" action="addsoldier.php?action=add">
<blockquote>
<p align="center">Real Name:
<input name="realname" type="text" id="realname">
</p>
</blockquote>

<blockquote>
<p align="center">Americas Army name (if you play)
<input name="americasarmyname" type="text" id="americasarmyname">
</p>
</blockquote>

<blockquote>
<p align="center">Military branch::
<input name="militarybranch" type="text" id="militarybranch">
</p>
</blockquote>
<blockquote>
<p align="center">Rank:
<input name="rank" type="text" id="rank">
</p>
</blockquote>
<blockquote>
<p align="center">MOS (occupation civilian terms)
<input name="mos" type="text" id="mos">
</p>
</blockquote>

<blockquote>
<p align="center">Based at (ship if Navy)
<input name="basedat" type="text" id="basedat">
</p>
</blockquote>

<blockquote>

<div align="center">
<p>How long have you served? (or serving)
<input name="servedanserving" type="text" id="servedanserving">
</p>
<p> </p>
</div>

<div align="center">
<input type="submit" name="Submit" value="Submit">
</div>
</form>
<p align="center"> </p>
</blockquote>
<?
}

if ( $action == "add" ) {
mysql_query("INSERT into tblmil ( fdrealn,fdaan,fdmilbranch,fdrank,fdmos,fdbased,fdserving) values ( '$Information has been added' ) ");
echo "$Information has been added";
}

mysql_close( $link );
?>

then to have it add you can't use
$Information has been added

as that is nothing and will error out. you need to fix your insert query to add the correct variables to the correct columns. and that all depeends on if you have register_globals off or on. but seeing as you are only using $action it might be on and that is a security issue.

johnsx2002
Sep 21st, 2003, 02:55 PM
I think its on, is that a problme? how can i fix it an how can i make it add i am a complete php nooobie! please help me brotha!

phpman
Sep 21st, 2003, 04:00 PM
it won't hurt you to read a little on the mysql and php sites either. on this line do this


if ( $action == "add" ) {
mysql_query("INSERT into tblmil ( fdrealn,fdaan,fdmilbranch,fdrank,fdmos,fdbased,fdserving) values ( '$realname','$americasarmyname','$militarybranch','$rank','$mos','$basedat','$servedanserving' ) ");
echo "$Information has been added";
}


try that.

johnsx2002
Sep 21st, 2003, 04:20 PM
Alright cool i'll check that out when i get home, i have a sql book an never payed attention to the sql / oracle class in HS :P too bad for me, well that'll probably do the trick, so thank ya!