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 4 of 4

Thread: PHP Error

  1. #1
    New Coder
    Join Date
    Mar 2009
    Posts
    97
    Thanks
    10
    Thanked 0 Times in 0 Posts

    PHP Error

    arning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/youronli/public_html/process.php on line 22

    Getting This Error...
    Here's my script...


    PHP Code:
    <?php 
    error_reporting
    (E_ALL);
    session_start();

    $dbHost ""// Database Connection Details - host
    $dbUser ""// Database Connection Details - username
    $dbPass ""// Database Connection Details - password
    $dbname ""// Database Connection Details - database name


    $db mysql_connect($dbHost,$dbUser,$dbPass); // Connection Code
    mysql_select_db($dbname,$db);                 // Connects to database

    if(isset($_POST['submit']))
    {
        
    $username $_POST['username'];
        
    $password $_POST['password'];
        
        
    $sql "SELECT * FROM users WHERE username = '$username' AND password = '$password'";
        
    $que mysql_query($sql);
        
        if(
    mysql_num_rows($que) == 1
        {
            
    $_SESSION['loggedin'] = 1;
            
    header("Location: usercp.php");
        }else
        {
            echo 
    "<font color=\"red\"> Error Wrong Login Details </font>";
            echo 
    "<a href=\"login.php\">Login Page</a>";
        }
    }
    ?>

  • #2
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    Its telling you that the query has failed. if you put the line
    PHP Code:
    echo $sql
    just under
    PHP Code:
    $sql "SELECT * FROM users WHERE username = '$username' AND password = '$password'"
    and see what comes out?
    You can not say you know how to do something, until you can teach it to someone else.

  • #3
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    Are sure that you've spelled users, username and password exactly as they are in the database?
    You can not say you know how to do something, until you can teach it to someone else.

  • #4
    New Coder
    Join Date
    Mar 2009
    Posts
    97
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Ah, dont matter i fixed it..i found out the guy im working with changed the connection info dammit! sorry about that


    Kevin


  •  

    Posting Permissions

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