Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

MySQL result resource

NeophyteNeophyte Member Posts: 1
Hi all ..

I hope you can help me with this, coz i simply cant figure it out! :(

Here is the code :

25: if ($id == "login") {
26: $password = $HTTP_POST_VARS["password"];
27: $username = $HTTP_POST_VARS["username"];
28:
29: // Authorization
30: $login = mysql_query("SELECT * FROM login WHERE username='$username' AND password='$password'");
31:
32: // If successfull
33: if (mysql_num_rows($login) == 1) {
34: echo "work dammit";
35: }
36: }

That gives me :
Warning: Supplied argument is not a valid MySQL result resource in /domains/xxx/xxx/xxx/index.php on line 33

The server is a linux server tho i really dont think it has anything to say here, checked for case sensitives..

Thanx in advance
Neophyte

Comments

  • turboturbo Member Posts: 2
    : Hi all ..
    :
    : I hope you can help me with this, coz i simply cant figure it out! :(
    :
    : Here is the code :
    :
    : 25: if ($id == "login") {
    : 26: $password = $HTTP_POST_VARS["password"];
    : 27: $username = $HTTP_POST_VARS["username"];
    : 28:
    : 29: // Authorization
    : 30: $login = mysql_query("SELECT * FROM login WHERE username='$username' AND password='$password'");
    : 31:
    : 32: // If successfull
    : 33: if (mysql_num_rows($login) == 1) {
    : 34: echo "work dammit";
    : 35: }
    : 36: }
    :
    : That gives me :
    : Warning: Supplied argument is not a valid MySQL result resource in /domains/xxx/xxx/xxx/index.php on line 33
    :
    : The server is a linux server tho i really dont think it has anything to say here, checked for case sensitives..
    :
    : Thanx in advance
    : Neophyte
    :
    Make sure you have a connection to the database somewhere before these lines

  • joebeewjoebeew Member Posts: 61
    : : Hi all ..
    : :
    : : I hope you can help me with this, coz i simply cant figure it out! :(
    : :
    : : Here is the code :
    : :
    : : 25: if ($id == "login") {
    : : 26: $password = $HTTP_POST_VARS["password"];
    : : 27: $username = $HTTP_POST_VARS["username"];
    : : 28:
    : : 29: // Authorization
    : : 30: $login = mysql_query("SELECT * FROM login WHERE username='$username' AND password='$password'");
    : : 31:
    : : 32: // If successfull
    : : 33: if (mysql_num_rows($login) == 1) {
    : : 34: echo "work dammit";
    : : 35: }
    : : 36: }
    : :
    : : That gives me :
    : : Warning: Supplied argument is not a valid MySQL result resource in /domains/xxx/xxx/xxx/index.php on line 33
    : :
    : : The server is a linux server tho i really dont think it has anything to say here, checked for case sensitives..
    : :
    : : Thanx in advance
    : : Neophyte
    : :
    : Make sure you have a connection to the database somewhere before these lines
    :
    :

    You need to pass the mysql_query to parameters.
    The first one = the Select string. the second one = the database reference

    [code]
    $db = mysql_connect("localhost","username","password") or die("Unable to connect to host");
    mysql_select_db("databasename",$db) or die("unable to select db");

    $login = mysql_query("Select * from table",$db);

    if (mysql_num_rows($login) <= 1){
    echo("It works");
    }else{
    echo("Doesn't work");
    }
    [/code]
Sign In or Register to comment.