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 6 of 6
  1. #1
    New Coder fireblade's Avatar
    Join Date
    May 2007
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Returns an eror in PHP/Mysql call..

    What is the error seems here beLow??

    PHP Code:
    function isPasswordMatch($email$password) {

        
    $SQL="SELECT email FROM user WHERE email='$email' AND Password=Password('$password')";
        
        
    $id=db_connect();
        if (
    $id) {
            
    $rs=mysql_query($SQL$id);
            
    $num_rows=mysql_num_rows($rs);
    // other gadjets goes here.... 
    this returns an error lice below
    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/www/photocity.freehostia.com/includes/php_database.php on line 161

  • #2
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    use mysql_fetch_array or mysql_fetch_row ?

  • #3
    New Coder
    Join Date
    Jun 2007
    Location
    VA
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by fireblade View Post
    What is the error seems here beLow??

    PHP Code:
    function isPasswordMatch($email$password) {

        
    $SQL="SELECT email FROM user WHERE email='$email' AND Password=Password('$password')";
        
        
    $id=db_connect();
        if (
    $id) {
            
    $rs=mysql_query($SQL$id);
            
    $num_rows=mysql_num_rows($rs);
    // other gadjets goes here.... 
    The problem is with your SQL statement. try using it like this instead:

    PHP Code:
    $SQL=SELECT email FROM USER WHERE email=$email AND Password=$password"; 

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Yes, your problem is with your query text, but Ddanatzko's code doesn't get you any closer to finding the problem. What you need to do is check your query for errors after you run it.

    Do this...
    PHP Code:
    function isPasswordMatch($email$password) {

        
    $SQL="SELECT email FROM user WHERE email='$email' AND Password=Password('$password')";
        
        
    $id=db_connect();
        if (
    $id) {
            
    $rs=mysql_query($SQL$id);
            if (!
    $rs) {
                die(
    "SQL Query Error! Query: $SQL<br />Error:".mysql_error());
            }
            
    $num_rows=mysql_num_rows($rs);
    // other gadjets goes here.... 

  • #5
    New Coder
    Join Date
    Jun 2007
    Location
    VA
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Fumigator's right, should have read the error message below the post.

  • #6
    New Coder fireblade's Avatar
    Join Date
    May 2007
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Thanks seniors,

    I got what the problem was there using the mysql_error() function.
    Actually the problem was my biggest mistake. I dint have selected any databases before running the query.

    Then I added the select_db() function it was working fine...

    Thanks for gining the idea.


  •  

    Posting Permissions

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