SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Addict trigger's Avatar
    Join Date
    Jun 2003
    Location
    Eagan
    Posts
    342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    start of user authentications script

    it won't return results of this query, even though I'm positive its right

    PHP Code:
    require_once('../Connections/Connection.php');
    mysql_select_db($database_Connection$Connection);
                    
    $query_result "SELECT * FROM access WHERE access.userName = '$userName' AND access.password = '$passWord'";
                    
    $result mysql_query($query_result$Connection) or die(mysql_error());
                    
    $row_result mysql_fetch_assoc($result);
                    
    $num mysql_num_rows($result);
                    echo 
    "$num results in the query"
    I'm running this off my local IIS server, and even though I'm positive I'm giving a userName and password that already match up, I keep getting zero results. Any ideas?

  2. #2
    Employed Again Viflux's Avatar
    Join Date
    May 2003
    Location
    London, On.
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try echo'ing the $userName and $passWord to see if they're what you think they are.

    You could also try running the query from the command line or whatever GUI-front to mysql you may have set up.

  3. #3
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try echoing $query_result, load up PHPMyAdmin, Copy & Paste the SQL into it, and see if it still returns zero results.

    That should narrow it down to a PHP connection problem, or a SQL problem (If you don't have or want PHPMyAdmin, just run MySQL from the command prompt)

    Edit:


    Lol, a minute apart!
    My name is Steve, and I'm a super-villian.

  4. #4
    SitePoint Addict trigger's Avatar
    Join Date
    Jun 2003
    Location
    Eagan
    Posts
    342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    echo $_POST['userName'];
    echo 
    $_POST['password']; 
    is not returning the password for some wierd reason, even though it runs down the script to the bottom, where I ask for the $num var. Do I need concantenation or something?

  5. #5
    SitePoint Addict trigger's Avatar
    Join Date
    Jun 2003
    Location
    Eagan
    Posts
    342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it looks like the connection script, now I can get a "1 result in the query", but now I can't set the cookie I want...
    PHP Code:
    $num mysql_num_rows($result);
                    echo 
    "$num results in the query";
                    if (
    $num != '0'){
                        
    setcookie("gsi_logged""1"time()+86400*120 "/" ".nasi.com" 0);
                        
    header "Location: http://www.nasi.com/GSI_Support/gsi_support_index.php");
                    }
                    else if (
    $num == '0'){
                        include ( 
    "Location: http://www.nasi.com/GSI_Support/loginFailed.php");
                    } 
    should I just say if $num = 1, or am I doing something wrong here?

  6. #6
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Modify the code to check $num as an integer, not a string (better performance, and possibly the source of the problem):

    PHP Code:
    if (mysql_num_rows($result) >= 1) {
       
    setcookie("gsi_logged""1"time()+86400*120 "/" ".nasi.com" 0);
       
    header "Location: http://www.nasi.com/GSI_Support/gsi_support_index.php");
    } else {
       include ( 
    "Location: http://www.nasi.com/GSI_Support/loginFailed.php");

    My name is Steve, and I'm a super-villian.

  7. #7
    Level 8 Chinese guy Archbob's Avatar
    Join Date
    Sep 2001
    Location
    Somewhere in this vast universe
    Posts
    3,741
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try putting
    PHP Code:
    $userName=$_POST['username'];
    $password=$_POST['password']; 
    before your SQL select statement. If you have globals turned off, you must do this.

    I'm not sure why your echo isn't returning anything.

  8. #8
    SitePoint Addict trigger's Avatar
    Join Date
    Jun 2003
    Location
    Eagan
    Posts
    342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    globals are turned on, it just seems like I had to test that query part of my script on the webserver, because it wasn't connection from my local test machine. I can't get the cookie to set though, that's what I don't understand. Globals are turned on, and the script runs through fine, but the cookie never sets.

  9. #9
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by trigger
    globals are turned on, it just seems like I had to test that query part of my script on the webserver, because it wasn't connection from my local test machine. I can't get the cookie to set though, that's what I don't understand. Globals are turned on, and the script runs through fine, but the cookie never sets.
    Try a different browser?

    Perhaps the one you are using is blocking it.
    My name is Steve, and I'm a super-villian.


Bookmarks

Posting Permissions

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