Results 1 to 9 of 9

Thread: parse error...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    oregon
    Posts
    88

    parse error...

    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.
    To get somthing out of life, you always need to be persistant.

  2. #2
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    <?
    //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 );
    ?>

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    oregon
    Posts
    88
    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...
    To get somthing out of life, you always need to be persistant.

  4. #4
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    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') ");

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    oregon
    Posts
    88
    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
    Last edited by johnsx2002; Sep 21st, 2003 at 11:25 AM.
    To get somthing out of life, you always need to be persistant.

  6. #6
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    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
    PHP Code:
    <?
    //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.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    oregon
    Posts
    88
    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!
    To get somthing out of life, you always need to be persistant.

  8. #8
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    it won't hurt you to read a little on the mysql and php sites either. on this line do this
    PHP Code:

    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.

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    oregon
    Posts
    88
    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!
    To get somthing out of life, you always need to be persistant.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width