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 7 of 7
  1. #1
    New Coder
    Join Date
    Mar 2008
    Posts
    10
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Registration and login working offline, but not online?!

    Thank you to everybody that helped, it seemed it was the md5 part of my code which was bugging up. I shouldn't have got involved with something I didn't know much about.
    Last edited by msredimp; 03-06-2008 at 12:35 AM.

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    Change your query to
    PHP Code:
    $query "SELECT * FROM users where login='$login' and pass='$password' LIMIT 1"
    and
    PHP Code:
    var_dump(mysql_num_rows($result)); 
    if that doesn't work.

  • #3
    New Coder
    Join Date
    Mar 2008
    Posts
    10
    Thanks
    5
    Thanked 0 Times in 0 Posts
    I changed the query to LIMIT 1, and that didn't work.
    PHP Code:
    $query "SELECT * FROM users where login='$login' and pass='$password' LIMIT 1"
    I then added var_dump infront of that part and it didn't work, so I removed != 1 and got this error:

    Parse error: syntax error, unexpected T_STRING, expecting '(' in ... on line 22
    PHP Code:
    if var_dump(mysql_num_rows($result)) { 

  • #4
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    2,958
    Thanks
    2
    Thanked 304 Times in 296 Posts
    My guess would be that register globals are on and all your various program/post/session variables with the same name are overwriting each other.

    Echo your query string in $query to see what it actually contains.

    Your mysql_query() also has no error checking, so it could be failing, which will result in mysql_num_rows() having a false value and your code will only tell you that the login failed.

    Each possible point of failure needs error checking (did it work or not), error reporting (tell the visitor a meaningful reason why the operation cannot be completed, and log all the available information for debugging purposes), and error recovery logic (what action do you take when there is an error, blindly continue executing on non-existent data or gracefully clean up and stop.)
    Last edited by CFMaBiSmAd; 03-06-2008 at 12:27 AM. Reason: Fixed some you/your typos
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • Users who have thanked CFMaBiSmAd for this post:

    msredimp (03-06-2008)

  • #5
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    PHP Code:
    if (var_dump(mysql_num_rows($result)))/* missing if's ()*/ 
    infact why are you using an if?
    PHP Code:
    var_dump(mysql_num_rows($result)); 
    is the instructions, follow as told

  • #6
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    Quote Originally Posted by msredimp View Post
    I changed the query to LIMIT 1, and that didn't work.
    PHP Code:
    $query "SELECT * FROM users where login='$login' and pass='$password' LIMIT 1"
    I then added var_dump infront of that part and it didn't work, so I removed != 1 and got this error:

    Parse error: syntax error, unexpected T_STRING, expecting '(' in ... on line 22
    PHP Code:
    if var_dump(mysql_num_rows($result)) { 
    No, don't change your existing if condition, just add it before the if() and after the query.

  • Users who have thanked Inigoesdr for this post:

    msredimp (03-06-2008)

  • #7
    New Coder
    Join Date
    Mar 2008
    Posts
    10
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Thank you everybody, problem solved. This thread is pretty useless as I was saying there was a problem where there wasn't. It was to do with the md5 part of my code.


  •  

    Posting Permissions

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