Web Analytics Made Easy -
StatCounter Strange error: $end - CodingForum

Announcement

Collapse
No announcement yet.

Strange error: $end

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Strange error: $end

    I'm trying to create a register form, with php validation. I've set it all up, with the form being submitted to RegisterAction.php which does the validation and INSERT query.
    When I submit the form, I get this error:
    Parse error: syntax error, unexpected $end in /path/to/file on line 68
    I have no idea what this means,
    Can you help?
    Thanks,
    ttttt
    http://openoffice.org/- Microsoft Office without the Microsoft.
    [home page][forum]
    Versatile, free software

  • #2
    Please post your code, I usually get this when I put no closing }.

    Comment


    • #3
      Ok:
      RegisterACtion.php
      PHP Code:
      <?php
      //Protect Against SQL injection - Do NOT remove!!!
      // Quote variable to make safe
      function quote_smart($psuser)
      {
         
      // Stripslashes
         
      if (get_magic_quotes_gpc()) {
             
      $psuser stripslashes($psuser);
         }
         
      // Quote if not a number or a numeric string
         
      if (!is_numeric($psuser)) {
             
      $psuser "'" mysql_real_escape_string($psuser) . "'";
         }
         return 
      $psuser;
      }
      //Do same for password
      function quote_smart($psPassword)
      {
         
      // Stripslashes
         
      if (get_magic_quotes_gpc()) {
             
      $psPassword stripslashes($psPassword);
         }
         
      // Quote if not a number or a numeric string
         
      if (!is_numeric($psPassword)) {
             
      $psPassword "'" mysql_real_escape_string($psPassword) . "'";
         }
         return 
      $psPassword;
      }
      //And email
      function quote_smart($psemail)
      {
         
      // Stripslashes
         
      if (get_magic_quotes_gpc()) {
             
      $psemail stripslashes($psemail);
         }
         
      // Quote if not a number or a numeric string
         
      if (!is_numeric($psuser)) {
             
      $psemail "'" mysql_real_escape_string($psemail) . "'";
         }
         return 
      $psemail;
      }
      // Check if the information has been filled in
      if($psuser == '' || $psPassword == '' || $psemail == '' || $psPasswordc == '') {
      header('Location: Login.php?refer='.urlencode($psRefer));

      else {
      //check the two passwords match
      if(!$psPassword == $psPasswordc) {
      //connect to the database
      @mysql_connect('localhost''user''pass');
      @
      mysql_select_db('home');
      $sql "INSERT INTO members SET
               id  = 'NULL',
               uname   = '
      $psuser',
               uemail = 'psemail',
               upass = MD5('
      $uPassword'),
               GUID = 'NULL',
               data = 'NULL',
               permissions = '1'"
      ;

      @
      mysql_query($sql);
      }
      else
      {
      header('Location: Login.php?refer='.urlencode($psRefer));
      }
      @
      mysql_close;
      ?>
      Thanks,
      ttttt
      http://openoffice.org/- Microsoft Office without the Microsoft.
      [home page][forum]
      Versatile, free software

      Comment


      • #4
        PHP Code:
        else {
        //check the two passwords match
        if(!$psPassword == $psPasswordc) {
        //connect to the database
        @mysql_connect('localhost''user''pass');
        @
        mysql_select_db('home');
        $sql "INSERT INTO members SET
                 id  = 'NULL',
                 uname   = '
        $psuser',
                 uemail = 'psemail',
                 upass = MD5('
        $uPassword'),
                 GUID = 'NULL',
                 data = 'NULL',
                 permissions = '1'"
        ;

        @
        mysql_query($sql);
        }
        else
        {
        header('Location: Login.php?refer='.urlencode($psRefer));
        }
        @
        mysql_close;
        // } here maybe?
        ?> 
        is missing a closing } as I said

        Comment


        • #5
          Thanks, also, could you help me with my php validation? I posted a while ago, but am still stuck. Is there anyway I can protect three variables from sql injection in one statement?
          Thanks again,
          ttttt
          http://openoffice.org/- Microsoft Office without the Microsoft.
          [home page][forum]
          Versatile, free software

          Comment


          • #6
            take a look at http://php.net/mysql-real-escape-string
            My thoughts on some things: http://codemeetsmusic.com
            And my scrapbook of cool things: http://gjones.tumblr.com

            Comment


            • #7
              But is just the mysql_escape_string secure enough on its own?
              Thanks,
              ttttt
              http://openoffice.org/- Microsoft Office without the Microsoft.
              [home page][forum]
              Versatile, free software

              Comment


              • #8
                Should be - thats what it's there for. It's enough to protect your injection query - but it's clearly not enough to decide if you've received the correct data from the user.
                Active PHP/MySQL application developer available for immediate work.
                syosoft.com mavieo.com - Remote Web Site Administration Suite - Reseller Ready

                Comment

                Working...
                X