error when posting to mysql w/ php

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • SuSe newbie

    error when posting to mysql w/ php

    If someone can help me out with this i would really appreciate it. I'm kind of new so don't bash my code too bad!!

    This is the error:
    Parse error: parse error, unexpected T_VARIABLE in /srv/www/htdocs/sendinfo.php on line 45

    This is the code:
    <?php
    $fname=$_POST['fname'];
    $lname=$_POST['lname'];
    $address=$_POST['address'];
    $address2=$_POS T['address2'];
    $address3=$_POS T['address3'];
    $citye=$_POST['city'];
    $state=$_POST['state'];
    $zip=$_POST['zip'];
    $phone=$_POST['phone'];
    $email=$_POST['email'];
    $subject="Data Added";
    $from=xxx@YYY.c om;
    $ipaddress = $_SERVER['REMOTE_ADDR'];

    mail("XXX@XXX.c om",$subject, "Street Address: $address\r\nCit y:$city\r\nZip: $zip\r\nIP: $ipaddress", "FROM: $from\r\n");
    echo "Your IP address is: $ipaddress";
    ?>

    <?php
    $username="XXX" ;
    $password="XXXX ";
    $database="XXXX ";
    $localhost="loc alhost";
    $fname= mysql_escape_st ring($_POST['fname']);
    $lname= mysql_escape_st ring($_POST['lname']);
    $address= mysql_escape_st ring($_POST['address']);
    $address2= mysql_escape_st ring($_POST['address2']);
    $address3= mysql_escape_st ring($_POST['address3']);
    $city= mysql_escape_st ring($_POST['city']);
    $state= mysql_escape_st ring($_POST['state']);
    $zip= mysql_escape_st ring($_POST['zip']);
    $phone= mysql_escape_st ring($_POST['phone']);
    $email= mysql_escape_st ring($_POST['email']);
    $ipaddress=mysq l_escape_string ($_SERVER['REMOTE_ADDR']
    $conn=mysql_con nect($localhost , $username, $password) or die("Unable to setup connection"); //This is the line the error is referencing
    mysql_select_db ($database,$con n) or die( "Unable to select database");
    $query = "INSERT INTO leads VALUES('$fname' ,'$lname','$add ress','$address 2','$address3', '$city','$state ','$zip','$phon e','$email',$ip address)";
    echo $query;
    mysql_query($qu ery) or die("Error: ".mysql_error() );
    mysql_close();
    ?>
  • SuSE Newbie

    #2
    Re: error when posting to mysql w/ php

    I got it, Thanks!!
    "SuSe newbie" <jkinney1@sc.rr .com> wrote in message news:TpmRb.1090 3$F86.1386574@t wister.southeas t.rr.com...
    If someone can help me out with this i would really appreciate it. I'm kind of new so don't bash my code too bad!!

    This is the error:
    Parse error: parse error, unexpected T_VARIABLE in /srv/www/htdocs/sendinfo.php on line 45

    This is the code:
    <?php
    $fname=$_POST['fname'];
    $lname=$_POST['lname'];
    $address=$_POST['address'];
    $address2=$_POS T['address2'];
    $address3=$_POS T['address3'];
    $citye=$_POST['city'];
    $state=$_POST['state'];
    $zip=$_POST['zip'];
    $phone=$_POST['phone'];
    $email=$_POST['email'];
    $subject="Data Added";
    $from=xxx@YYY.c om;
    $ipaddress = $_SERVER['REMOTE_ADDR'];

    mail("XXX@XXX.c om",$subject, "Street Address: $address\r\nCit y:$city\r\nZip: $zip\r\nIP: $ipaddress", "FROM: $from\r\n");
    echo "Your IP address is: $ipaddress";
    ?>

    <?php
    $username="XXX" ;
    $password="XXXX ";
    $database="XXXX ";
    $localhost="loc alhost";
    $fname= mysql_escape_st ring($_POST['fname']);
    $lname= mysql_escape_st ring($_POST['lname']);
    $address= mysql_escape_st ring($_POST['address']);
    $address2= mysql_escape_st ring($_POST['address2']);
    $address3= mysql_escape_st ring($_POST['address3']);
    $city= mysql_escape_st ring($_POST['city']);
    $state= mysql_escape_st ring($_POST['state']);
    $zip= mysql_escape_st ring($_POST['zip']);
    $phone= mysql_escape_st ring($_POST['phone']);
    $email= mysql_escape_st ring($_POST['email']);
    $ipaddress=mysq l_escape_string ($_SERVER['REMOTE_ADDR']
    $conn=mysql_con nect($localhost , $username, $password) or die("Unable to setup connection"); //This is the line the error is referencing
    mysql_select_db ($database,$con n) or die( "Unable to select database");
    $query = "INSERT INTO leads VALUES('$fname' ,'$lname','$add ress','$address 2','$address3', '$city','$state ','$zip','$phon e','$email',$ip address)";
    echo $query;
    mysql_query($qu ery) or die("Error: ".mysql_error() );
    mysql_close();
    ?>

    Comment

    • Cameron

      #3
      Re: error when posting to mysql w/ php

      SuSe newbie wrote:[color=blue]
      > If someone can help me out with this i would really appreciate it. I'm
      > kind of new so don't bash my code too bad!!
      >[/color]
      <code snip>

      Missing semicolon on line above one with the error

      ~Cameron

      Comment

      • SuSE Newbie

        #4
        Re: error when posting to mysql w/ php

        I got it, Thanks!!
        "SuSe newbie" <jkinney1@sc.rr .com> wrote in message news:TpmRb.1090 3$F86.1386574@t wister.southeas t.rr.com...
        If someone can help me out with this i would really appreciate it. I'm kind of new so don't bash my code too bad!!

        This is the error:
        Parse error: parse error, unexpected T_VARIABLE in /srv/www/htdocs/sendinfo.php on line 45

        This is the code:
        <?php
        $fname=$_POST['fname'];
        $lname=$_POST['lname'];
        $address=$_POST['address'];
        $address2=$_POS T['address2'];
        $address3=$_POS T['address3'];
        $citye=$_POST['city'];
        $state=$_POST['state'];
        $zip=$_POST['zip'];
        $phone=$_POST['phone'];
        $email=$_POST['email'];
        $subject="Data Added";
        $from=xxx@YYY.c om;
        $ipaddress = $_SERVER['REMOTE_ADDR'];

        mail("XXX@XXX.c om",$subject, "Street Address: $address\r\nCit y:$city\r\nZip: $zip\r\nIP: $ipaddress", "FROM: $from\r\n");
        echo "Your IP address is: $ipaddress";
        ?>

        <?php
        $username="XXX" ;
        $password="XXXX ";
        $database="XXXX ";
        $localhost="loc alhost";
        $fname= mysql_escape_st ring($_POST['fname']);
        $lname= mysql_escape_st ring($_POST['lname']);
        $address= mysql_escape_st ring($_POST['address']);
        $address2= mysql_escape_st ring($_POST['address2']);
        $address3= mysql_escape_st ring($_POST['address3']);
        $city= mysql_escape_st ring($_POST['city']);
        $state= mysql_escape_st ring($_POST['state']);
        $zip= mysql_escape_st ring($_POST['zip']);
        $phone= mysql_escape_st ring($_POST['phone']);
        $email= mysql_escape_st ring($_POST['email']);
        $ipaddress=mysq l_escape_string ($_SERVER['REMOTE_ADDR']
        $conn=mysql_con nect($localhost , $username, $password) or die("Unable to setup connection"); //This is the line the error is referencing
        mysql_select_db ($database,$con n) or die( "Unable to select database");
        $query = "INSERT INTO leads VALUES('$fname' ,'$lname','$add ress','$address 2','$address3', '$city','$state ','$zip','$phon e','$email',$ip address)";
        echo $query;
        mysql_query($qu ery) or die("Error: ".mysql_error() );
        mysql_close();
        ?>

        Comment

        • SuSe newbie

          #5
          Re: error when posting to mysql w/ php

          thanks Cameron,
          now i'm getting an error on that line for
          Parse error: parse error, unexpected ';' in /srv/www/htdocs/sendinfo.php on
          line 43
          any ideas??
          "Cameron" <foo@bar.invali d> wrote in message
          news:bv4s8l$iqu $1@news5.svr.po l.co.uk...[color=blue]
          > SuSe newbie wrote:[color=green]
          > > If someone can help me out with this i would really appreciate it. I'm
          > > kind of new so don't bash my code too bad!!
          > >[/color]
          > <code snip>
          >
          > Missing semicolon on line above one with the error
          >
          > ~Cameron[/color]


          Comment

          • Cameron

            #6
            Re: error when posting to mysql w/ php

            SuSe newbie wrote:[color=blue]
            > thanks Cameron,
            > now i'm getting an error on that line for
            > Parse error: parse error, unexpected ';' in /srv/www/htdocs/sendinfo.php on
            > line 43
            > any ideas??
            > "Cameron" <foo@bar.invali d> wrote in message
            > news:bv4s8l$iqu $1@news5.svr.po l.co.uk...
            >[color=green]
            >>SuSe newbie wrote:
            >>[color=darkred]
            >>>If someone can help me out with this i would really appreciate it. I'm
            >>>kind of new so don't bash my code too bad!!
            >>>[/color]
            >>
            >><code snip>
            >>
            >>Missing semicolon on line above one with the error
            >>
            >>~Cameron[/color]
            >
            >
            >[/color]

            ah yes sorry, on the same line that had the missing semicolon there is
            also a missing ) so it should end with );

            Comment

            • Chris Dingman

              #7
              Re: error when posting to mysql w/ php

              Missing closing parentheses on that line.

              --
              Chris Dingman
              Webmaster
              Cabaret Theatre
              Since 1975, Cabaret Theatre has been committed to providing Rutgers University-New Brunswick and its surrounding community with a wide variety of theatrical experiences.


              Now selling officially licensed Cabaret Theatre merchandise
              "SuSe newbie" <jkinney1@sc.rr .com> wrote in message
              news:rzmRb.1095 2$F86.1387722@t wister.southeas t.rr.com...[color=blue]
              > thanks Cameron,
              > now i'm getting an error on that line for
              > Parse error: parse error, unexpected ';' in /srv/www/htdocs/sendinfo.php[/color]
              on[color=blue]
              > line 43
              > any ideas??
              > "Cameron" <foo@bar.invali d> wrote in message
              > news:bv4s8l$iqu $1@news5.svr.po l.co.uk...[color=green]
              > > SuSe newbie wrote:[color=darkred]
              > > > If someone can help me out with this i would really appreciate it.[/color][/color][/color]
              I'm[color=blue][color=green][color=darkred]
              > > > kind of new so don't bash my code too bad!!
              > > >[/color]
              > > <code snip>
              > >
              > > Missing semicolon on line above one with the error
              > >
              > > ~Cameron[/color]
              >
              >[/color]


              Comment

              • SuSe newbie

                #8
                Re: error when posting to mysql w/ php

                Thanks guys, i've gotten rid of those bugs now. I figured it was something
                stupid. I hope this is the last time i'll ask, but i'm getting a new error
                now. Check this out and let me know what you think:
                Your IP address is: XX.XX.XX.XX INSERT INTO leads
                VALUES('test',' test','test','t est','test','te st','sc','55555 ','5555555555', '
                anon@anon.com', XX.XX.XX.XX)Error: You have an error in your SQL syntax near
                '.148.78)' at line 1
                "Chris Dingman" <dinger@cabaret theatre.org> wrote in message
                news:rDmRb.1109 8$x05.7253@nwrd ny03.gnilink.ne t...[color=blue]
                > Missing closing parentheses on that line.
                >
                > --
                > Chris Dingman
                > Webmaster
                > Cabaret Theatre
                > http://www.cabarettheatre.org
                >
                > Now selling officially licensed Cabaret Theatre merchandise
                > "SuSe newbie" <jkinney1@sc.rr .com> wrote in message
                > news:rzmRb.1095 2$F86.1387722@t wister.southeas t.rr.com...[color=green]
                > > thanks Cameron,
                > > now i'm getting an error on that line for
                > > Parse error: parse error, unexpected ';' in /srv/www/htdocs/sendinfo.php[/color]
                > on[color=green]
                > > line 43
                > > any ideas??
                > > "Cameron" <foo@bar.invali d> wrote in message
                > > news:bv4s8l$iqu $1@news5.svr.po l.co.uk...[color=darkred]
                > > > SuSe newbie wrote:
                > > > > If someone can help me out with this i would really appreciate it.[/color][/color]
                > I'm[color=green][color=darkred]
                > > > > kind of new so don't bash my code too bad!!
                > > > >
                > > > <code snip>
                > > >
                > > > Missing semicolon on line above one with the error
                > > >
                > > > ~Cameron[/color]
                > >
                > >[/color]
                >
                >[/color]


                Comment

                • SuSE Newbie

                  #9
                  Re: error when posting to mysql w/ php

                  I got it, Thanks!!
                  "SuSe newbie" <jkinney1@sc.rr .com> wrote in message news:TpmRb.1090 3$F86.1386574@t wister.southeas t.rr.com...
                  If someone can help me out with this i would really appreciate it. I'm kind of new so don't bash my code too bad!!

                  This is the error:
                  Parse error: parse error, unexpected T_VARIABLE in /srv/www/htdocs/sendinfo.php on line 45

                  This is the code:
                  <?php
                  $fname=$_POST['fname'];
                  $lname=$_POST['lname'];
                  $address=$_POST['address'];
                  $address2=$_POS T['address2'];
                  $address3=$_POS T['address3'];
                  $citye=$_POST['city'];
                  $state=$_POST['state'];
                  $zip=$_POST['zip'];
                  $phone=$_POST['phone'];
                  $email=$_POST['email'];
                  $subject="Data Added";
                  $from=xxx@YYY.c om;
                  $ipaddress = $_SERVER['REMOTE_ADDR'];

                  mail("XXX@XXX.c om",$subject, "Street Address: $address\r\nCit y:$city\r\nZip: $zip\r\nIP: $ipaddress", "FROM: $from\r\n");
                  echo "Your IP address is: $ipaddress";
                  ?>

                  <?php
                  $username="XXX" ;
                  $password="XXXX ";
                  $database="XXXX ";
                  $localhost="loc alhost";
                  $fname= mysql_escape_st ring($_POST['fname']);
                  $lname= mysql_escape_st ring($_POST['lname']);
                  $address= mysql_escape_st ring($_POST['address']);
                  $address2= mysql_escape_st ring($_POST['address2']);
                  $address3= mysql_escape_st ring($_POST['address3']);
                  $city= mysql_escape_st ring($_POST['city']);
                  $state= mysql_escape_st ring($_POST['state']);
                  $zip= mysql_escape_st ring($_POST['zip']);
                  $phone= mysql_escape_st ring($_POST['phone']);
                  $email= mysql_escape_st ring($_POST['email']);
                  $ipaddress=mysq l_escape_string ($_SERVER['REMOTE_ADDR']
                  $conn=mysql_con nect($localhost , $username, $password) or die("Unable to setup connection"); //This is the line the error is referencing
                  mysql_select_db ($database,$con n) or die( "Unable to select database");
                  $query = "INSERT INTO leads VALUES('$fname' ,'$lname','$add ress','$address 2','$address3', '$city','$state ','$zip','$phon e','$email',$ip address)";
                  echo $query;
                  mysql_query($qu ery) or die("Error: ".mysql_error() );
                  mysql_close();
                  ?>

                  Comment

                  • Filth

                    #10
                    Re: error when posting to mysql w/ php


                    $citye=$_POST['city'];

                    I dont know if you have noticed but the varible here has an e on the end of
                    city but everywhere else it does not


                    Comment

                    • Filth

                      #11
                      Re: error when posting to mysql w/ php


                      $citye=$_POST['city'];

                      I dont know if you have noticed but the varible here has an e on the end of
                      city but everywhere else it does not


                      Comment

                      • Filth

                        #12
                        Re: error when posting to mysql w/ php


                        $citye=$_POST['city'];

                        I dont know if you have noticed but the varible here has an e on the end of
                        city but everywhere else it does not


                        Comment

                        • Andrew DeFaria

                          #13
                          Re: error when posting to mysql w/ php

                          SuSe newbie wrote:
                          [color=blue]
                          > Thanks guys, i've gotten rid of those bugs now. I figured it was
                          > something stupid. I hope this is the last time i'll ask, but i'm
                          > getting a new error now. Check this out and let me know what you
                          > think: Your IP address is: XX.XX.XX.XX INSERT INTO leads
                          > VALUES('test',' test','test','t est','test','te st','sc','55555 ','5555555555', '
                          > anon@anon.com', XX.XX.XX.XX)Error: You have an error in your SQL syntax
                          > near
                          > '.148.78)' at line 1[/color]

                          Everything in the values section is quoted (surrounded by single quotes)
                          except the IP address.
                          --
                          I won't rise to the occaasion, but I'll slide over to it.

                          Comment

                          • Andrew DeFaria

                            #14
                            Re: error when posting to mysql w/ php

                            SuSe newbie wrote:
                            [color=blue]
                            > Thanks guys, i've gotten rid of those bugs now. I figured it was
                            > something stupid. I hope this is the last time i'll ask, but i'm
                            > getting a new error now. Check this out and let me know what you
                            > think: Your IP address is: XX.XX.XX.XX INSERT INTO leads
                            > VALUES('test',' test','test','t est','test','te st','sc','55555 ','5555555555', '
                            > anon@anon.com', XX.XX.XX.XX)Error: You have an error in your SQL syntax
                            > near
                            > '.148.78)' at line 1[/color]

                            Everything in the values section is quoted (surrounded by single quotes)
                            except the IP address.
                            --
                            I won't rise to the occaasion, but I'll slide over to it.

                            Comment

                            • Andrew DeFaria

                              #15
                              Re: error when posting to mysql w/ php

                              SuSe newbie wrote:
                              [color=blue]
                              > Thanks guys, i've gotten rid of those bugs now. I figured it was
                              > something stupid. I hope this is the last time i'll ask, but i'm
                              > getting a new error now. Check this out and let me know what you
                              > think: Your IP address is: XX.XX.XX.XX INSERT INTO leads
                              > VALUES('test',' test','test','t est','test','te st','sc','55555 ','5555555555', '
                              > anon@anon.com', XX.XX.XX.XX)Error: You have an error in your SQL syntax
                              > near
                              > '.148.78)' at line 1[/color]

                              Everything in the values section is quoted (surrounded by single quotes)
                              except the IP address.
                              --
                              I won't rise to the occaasion, but I'll slide over to it.

                              Comment

                              Working...