Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2011
    Location
    Maryland
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Cannot get my query

    I've been working on this for awhile, and I cannot not seem to find where my problem lies. For some reason or another I always seem to get a query fail.

    PHP Code:
    if(isset($_POST[action]))
    {
        
    mysql_connect("localhost""root""rootpw") or die("Could not connect to database");
        
    mysql_select_db("user") or die("Could not select database");
        
    $query "SELECT userid, password FROM signup WHERE userid=$_POST[userid]";
        
    $result mysql_query($query) or die("Query failed");
        
    $logininfo mysql_fetch_array($resultMYSQL_ASSOC);
        
        if((
    $_POST[userid] == $logininfo[userid]) && ($_POST[password] == $logininfo[password]))
        {
            
    header("Location: success.html");
        }
        else
        {
            
    header("Location: fail.html");
        }

    can someone spot an error in my coding?

  • #2
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    Looks like you just need to do some Basic Debugging 101 to find your error.

    As a start echo out the actual query being run and make sure the values passed to it and the syntax are correct.
    PHP Code:
    $query "SELECT userid, password FROM signup WHERE userid=$_POST[userid]";
    echo 
    $query; die(); 


  •  

    Posting Permissions

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