• Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Need Some PHP Help

Tyler

PHP Scripter
  • 620
    Posts
    19
    Years
    Im always getting a "Could not execute error" and i dont know what im doing wrong can someone please help me. I have all my database info set up it just doesnt want to execute

    Form Script:
    HTML:
    <html>
    <head>
    </head>
    
    <body>
    <form action="register2.php" method="post">
    Username: <form type="text" name="user" value="user"><br>
    Password: <form type="password" name="pass" value="pass"><br>
    <input type="submit" value="Submit">
    </form>
    </body>
    </html>
    PHP Script:
    PHP:
    <html>
    <head>
    </head>
    <body>
    <?php 
        $self = $_SERVER['PHP_SELF'];
        $user = $_POST['user'];
        $pass = $_POST['pass'];
    
    
    { $conn = @mysql_connect( "localhost", "u70423688","284ad1" )
        or die("Could not connect to MYSQL"); #Connecting to MYSQL
    $db = @mysql_select_db( "d60385531", $conn )
        or die("Could not select database"); #select database
    $sql = "insert into users
        (user,pass) values
        (\"$user\",password(\"$pass\") )";
    $result = @mysql_query( $sql, $conn )
        or die("Could not execute query");
    if( $result ) { echo( "New user $user added" ); }
    }
    ?>
    </body>
    </html>
     
    You just messed up your form.

    It wouldn't be the HTML, cause the PHP is generating that error. It's obviously a problem with your SQL statment, which is the following piece of code:

    $sql = "insert into users
    (user,pass) values
    (\"$user\",password(\"$pass\") )";
    $result = @mysql_query( $sql, $conn )
    or die("Could not execute query");

    Personally, I would change it to something like this:

    PHP:
    $result = mysql_query("INSERT INTO users (user, password) VALUES ('$user', '$pass')") or die("Could not execute query!");

    And I would md5 the password in PHP, cause I don't know what the password function that you have included in your query does.

    Hope that helps!
     
    But I'm looking at both his and yours side by side, and there's no difference. How could the form be the problem?

    And I would suggest adding mysql_error() to your die so you can see the actual reason for the error.
     
    Back
    Top