Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Http 500 error with register page

Http 500 error with register page

Scheduled Pinned Locked Moved Database
helpdatabasequestion
16 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A and180y

    Hi Could anyone help me with the following code? It was working fine until I inserted a username column in the DB table and edited this to suit (I thought) It gives an HTTP500 error page not working.

    Richard DeemingR Offline
    Richard DeemingR Offline
    Richard Deeming
    wrote on last edited by
    #5

    and180y wrote:

    $sql = "INSERT INTO users (email, username, password) VALUES (?, ?)";
    ...
    mysqli_stmt_bind_param($stmt, "ss", $param_email, $param_username $param_password);

    Two obvious problems: You're inserting into three columns, but you've only specified two values:

    $sql = "INSERT INTO users (email, username, password) VALUES (?, ?, ?)";

    You've only specified types for two parameters, and you're missing a comma between the last two parameters:

    mysqli_stmt_bind_param($stmt, "sss", $param_email, $param_username, $param_password);


    "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

    "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

    A 2 Replies Last reply
    0
    • Richard DeemingR Richard Deeming

      and180y wrote:

      $sql = "INSERT INTO users (email, username, password) VALUES (?, ?)";
      ...
      mysqli_stmt_bind_param($stmt, "ss", $param_email, $param_username $param_password);

      Two obvious problems: You're inserting into three columns, but you've only specified two values:

      $sql = "INSERT INTO users (email, username, password) VALUES (?, ?, ?)";

      You've only specified types for two parameters, and you're missing a comma between the last two parameters:

      mysqli_stmt_bind_param($stmt, "sss", $param_email, $param_username, $param_password);


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      A Offline
      A Offline
      and180y
      wrote on last edited by
      #6

      Thanks for replying Richard. :) I've fixed those errors but still having the same issue, it loaded the form once but now just a white page with the error.

      1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        and180y wrote:

        $sql = "INSERT INTO users (email, username, password) VALUES (?, ?)";
        ...
        mysqli_stmt_bind_param($stmt, "ss", $param_email, $param_username $param_password);

        Two obvious problems: You're inserting into three columns, but you've only specified two values:

        $sql = "INSERT INTO users (email, username, password) VALUES (?, ?, ?)";

        You've only specified types for two parameters, and you're missing a comma between the last two parameters:

        mysqli_stmt_bind_param($stmt, "sss", $param_email, $param_username, $param_password);


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        A Offline
        A Offline
        and180y
        wrote on last edited by
        #7

        I have played around starting again from the basic code and adding in what I need and checking for errors, all is fine till I put the code below in.

         }
        
        // Validate email
        if(empty(trim($\_POST\["email"\]))){
            $email\_err = "Please enter your email.";     
        } elseif(strlen(trim($\_POST\["email"\])) < 6){
            $email\_err = "email must have at least 6 characters.";
        } else{
            $email = trim($\_POST\["email"\]);
        }
        
        L 1 Reply Last reply
        0
        • A and180y

          I have played around starting again from the basic code and adding in what I need and checking for errors, all is fine till I put the code below in.

           }
          
          // Validate email
          if(empty(trim($\_POST\["email"\]))){
              $email\_err = "Please enter your email.";     
          } elseif(strlen(trim($\_POST\["email"\])) < 6){
              $email\_err = "email must have at least 6 characters.";
          } else{
              $email = trim($\_POST\["email"\]);
          }
          
          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #8

          if(empty(trim($_POST["email"]))){

          If the email variable is blank then calling trim on it will fail. You should change it to:

          if(empty($_POST["email"])){

          A 1 Reply Last reply
          0
          • L Lost User

            if(empty(trim($_POST["email"]))){

            If the email variable is blank then calling trim on it will fail. You should change it to:

            if(empty($_POST["email"])){

            A Offline
            A Offline
            and180y
            wrote on last edited by
            #9

            Working perfect now. Thanks Richard. :)

            L 1 Reply Last reply
            0
            • A and180y

              Working perfect now. Thanks Richard. :)

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #10

              You're welcome.

              A 1 Reply Last reply
              0
              • L Lost User

                You're welcome.

                A Offline
                A Offline
                and180y
                wrote on last edited by
                #11

                Richard, is there an error log generated somewhere for the DB? I get an intermittent fault (loads of folk saying the can't register but I can see some are able to) This is the error that shows on the form so not of much use. lol "Something went wrong. Please try again later".

                L 1 Reply Last reply
                0
                • A and180y

                  Richard, is there an error log generated somewhere for the DB? I get an intermittent fault (loads of folk saying the can't register but I can see some are able to) This is the error that shows on the form so not of much use. lol "Something went wrong. Please try again later".

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #12

                  Sorry, I don't know offhand. Check the MySQL documentation. I see that you are posting that message in your code. So you need to check why the call to mysqli_stmt_execute failed.

                  A 2 Replies Last reply
                  0
                  • L Lost User

                    Sorry, I don't know offhand. Check the MySQL documentation. I see that you are posting that message in your code. So you need to check why the call to mysqli_stmt_execute failed.

                    A Offline
                    A Offline
                    and180y
                    wrote on last edited by
                    #13

                    Thanks Richard, I edited as you said the other night but wonder if my issue is somewhere in here?

                    if(empty($_POST["email"])){
                    $email_err = "Please enter your email.";
                    } elseif(strlen(trim($_POST["email"])) < 6){
                    $email_err = "email must have at least 6 characters.";
                    } else{
                    $email = trim($_POST["email"]);
                    }
                    }

                    1 Reply Last reply
                    0
                    • L Lost User

                      Sorry, I don't know offhand. Check the MySQL documentation. I see that you are posting that message in your code. So you need to check why the call to mysqli_stmt_execute failed.

                      A Offline
                      A Offline
                      and180y
                      wrote on last edited by
                      #14

                      Thanks Richard, progress made. There is no error as such, if you try to register with the same email twice (yes I thought that as well) it throws the error I mentioned but isn't telling them the email is already registered. It does for username but the email was the bit I added in. :-)

                      L 1 Reply Last reply
                      0
                      • A and180y

                        Thanks Richard, progress made. There is no error as such, if you try to register with the same email twice (yes I thought that as well) it throws the error I mentioned but isn't telling them the email is already registered. It does for username but the email was the bit I added in. :-)

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #15

                        Did you not realise that you first need to check whether the email is already registered?

                        A 1 Reply Last reply
                        0
                        • L Lost User

                          Did you not realise that you first need to check whether the email is already registered?

                          A Offline
                          A Offline
                          and180y
                          wrote on last edited by
                          #16

                          Hi Richard, thanks. :) Everyday is a school day dealing with the humans I do. :)

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups