Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2004
    Location
    Canada
    Posts
    57

    Unanswered: Simple query is driving me mad !!!

    Hi there!

    In my script I use the following code:

    Code:
    $table = "_lisausers"; 
    $mypassword; //this is a 'POST' variable
    $query =mysql_query("SELECT pwd FROM `$table` WHERE pwd LIKE '$mypassword'" ) or die();
    if (mysql_num_rows( $query ) > 0) {
    	print "&retour=true";
    }
    else {
    	print "&retour=false";
    }
    Despite the fact that $mypassword already exists in the $table, this query always gives me a wrong result if I ask an existing or not pwd in this table !!!

    Would you tell me what's wrong in this query and the if/else block?

    Many thanks in advance for your help!

    Regards,
    Gerry

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    on the face of it it looks OK
    so either the select isn't finding any rows for the specified values
    OR
    there is something odd going on with MySQL

    my first guess would be the '$table', php will replace the value of $table, so in effect your query is reading
    "SELECT pwd FROM `_lisausers`....

    next would be the where clause
    are you certain that $mypassword contains a value that is in the db.

    If SQL aint doing what I expect, I always want to see the SQL that is actually being sent tot he server, it may not be what you think it is. If the SQL looks ok then I like to place the same SQL into a query browser just to verify its legit

    one way of checking the basic functioning of the logic is to temporarily replace the SQL in question with something that is known to work, ie without a "where clause".

    is the password encyrpted in the db (ideally it should be, otherwise you have the same weakness as no password, ie the user can see their password). if so are you certain that you are using the same encryption method in both cases. it can be difficult to manually do a comparison between encrypted passwords.

    HTH

  3. #3
    Join Date
    Mar 2007
    Location
    636f6d7075746572
    Posts
    770
    Try :
    Code:
    SELECT * FROM $table
    That should give you some results. If this is the case then as healdem suggests it's probably a problem with your where clause, your column selection, or the possibility that you have encrypted passwords in the table??

    Either way put in a "echo mysql_error();" at the bottom of your script to see if you're getting any errors.

  4. #4
    Join Date
    Apr 2004
    Location
    Canada
    Posts
    57
    The problem is solved !!!

    All the PHP is OK.
    It's only the way I manipulate the results in my .swf file which was wrong !
    Silly of me.

    I thank you both for your interest and your help.
    Best regards,

    Gerry

Posting Permissions

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