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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Nov 2007
    Location
    Leeds, UK
    Posts
    514
    Thanks
    24
    Thanked 19 Times in 19 Posts

    SQL Sintax Error

    Code:
    $query = mysql_query("SELECT * FROM `Users` WHERE `Username` = '$_POST[user]' AND `Password` = '$pass'");
    while($row = mysql_fetch_array($query))
    {
    $_SESSION['Username'] = $row['username'];
    $_SESSION['UserID'] = $row['ID'];
    }
    returns this error

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home1/barkersm/public_html/irc/login.php on line 44

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    mysql_query() is returning false because your query is failing. Change your query to this to get more info:
    PHP Code:
    $query mysql_query("SELECT * FROM `Users` WHERE `Username` = '{$_POST['user']}' AND `Password` = '$pass'") or die(mysql_error()); 
    And make sure you pass all user input through mysql_real_escape_string() before using it in a query.

  • Users who have thanked Inigoesdr for this post:

    barkermn01 (01-14-2008)

  • #3
    Senior Coder ahallicks's Avatar
    Join Date
    May 2006
    Location
    Lancaster, UK
    Posts
    1,134
    Thanks
    1
    Thanked 57 Times in 55 Posts
    And 'sintax' is actually spelt 'syntax'

    (sorry, felt the need to add that in there)
    "write it for FireFox then hack it for IE."
    Quote Originally Posted by Mhtml View Post
    Domains are like women - all the good ones are taken unless you want one from some foreign country.
    Reputation is your friend

    Development & SEO Tools

  • #4
    Regular Coder
    Join Date
    Nov 2007
    Location
    Leeds, UK
    Posts
    514
    Thanks
    24
    Thanked 19 Times in 19 Posts
    thanks


  •  

    Posting Permissions

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