SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    Free me php klassicd's Avatar
    Join Date
    Sep 2001
    Location
    San Diego
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with error.

    I have tried everything in my mind to get this too work. Im going to see if anyone else can. The problem is is when someone trys to access viewpmsg.php i get this error.....

    Warning: Supplied argument is not a valid MySQL-Link resource in /web/sites/178/kfoolio/www.kfoolio.f2s.com/html/functions.php on line 360

    Error doing DB query in check_user_pw()


    When i go into functions.php i see this:


    function check_user_pw($username, $password, $db) {
    global $system, $prefix;
    if (!$system) {
    $password = crypt($password,substr($password,0,2));
    } else {
    $password = $password;
    }
    #$password = md5($password);
    $username = addslashes($username);
    $sql = "SELECT user_id FROM users WHERE (username = '$username') AND (user_password = '$password')";
    $resultID = mysql_query($sql, $db); //this is line 360
    if (!$resultID) {
    echo mysql_error() . "<br>";
    die("Error doing DB query in check_user_pw()");
    }
    return mysql_num_rows($resultID);
    } // check_user_pw()

    I dont see a thing wrong with it. does anyone have any ideas?

  2. #2
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The $db that check_user_pw is getting is not a valid MySQL connection handle/link. Are you sure there were no errors connecting?

    Also...if you only have 1 MySQL connection then you don't need to supply the connection handle to the mysql_* functions.

  3. #3
    SitePoint Guru
    Join Date
    Jan 2001
    Location
    Alkmaar, Netherlands
    Posts
    710
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    function check_user_pw($username, $password, &$db)

  4. #4
    Free me php klassicd's Avatar
    Join Date
    Sep 2001
    Location
    San Diego
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Nope

    I know its an error connecting, but i still cant seem to find it. And yes i need to have the $db cause i have multiple connections.

    And in reply to sylow i tried that and it didnt help. I was wondering why you even put that. I have never seen it written that way before.

    Thanks for your help anyways.

  5. #5
    SitePoint Enthusiast smashway's Avatar
    Join Date
    Sep 2001
    Location
    Lausanne, Switzerland
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Help with error.


    $resultID = mysql_query($sql, $db); //this is line 360
    you should modify this with
    Code:
    $resultID = mysql_query($sql, $db) or die(mysql_error());
    like this, you'll be able to actually see the potential error messages!
    Smash

    Check this thread and help me: click here!

  6. #6
    Free me php klassicd's Avatar
    Join Date
    Sep 2001
    Location
    San Diego
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Well

    Its definitly an error connecting to the database. I just cant seem to find out what it is. This is the only function in my script that doesnt seem to work and its set up like the rest. well if i cant solve it i guess i will just have to take it out.

  7. #7
    SitePoint Enthusiast smashway's Avatar
    Join Date
    Sep 2001
    Location
    Lausanne, Switzerland
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    check your $db link identifier. Where is it supposed to be assigned? try to trace it through your code... Check for variables/values speling errors too
    That call to mysql_query() looks a bit confusing to me... Are you tryging to connect to different database SERVERS? or just to different databases on the same server? in the latter case you'd better use mysql_db_query(); more info about that function can be found here

    Hope it helps,
    Last edited by smashway; Sep 3, 2001 at 23:55.
    Smash

    Check this thread and help me: click here!


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
  •