Why Not it doesn't Work???

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kasya
    New Member
    • Jun 2006
    • 57

    Why Not it doesn't Work???

    <? Error_Reporting (E_ALL & ~E_NOTICE);

    function auth($user_name ,$user_pass) {
    mysql_connect(" localhost","roo t","") or die("ERROR:1");
    mysql_select_db ("Kasya") or die("ERROR:2");
    $query = "SELECT * FROM `user_info` VALUES('user_na me','user_pass' )";
    $result = mysql_query($qu ery);

    $inf = mysql_fetch_arr ay($result);

    if($inf['user_name'] == $user_name and $inf['user_pass'] == $user_pass) {


    echo("Access Allow!");


    }

    else {
    die("Access Denied! Invalid Username or Password!");

    }

    }



    echo "

    <form action='$PHP_SE LF' method='post'>
    UserName: <input type='text' name='name'><br/>
    Password: <input type='password' name='pass'><br/>
    <input type='submit' name='ok' value='Enter'>
    </form>

    ";



    $user = $_POST['user'];
    $pass = $_POST['pass'];
    $ok = $_POST['ok'];

    auth($user,$pas s);

    ?>

    Errors:

    Warning: mysql_fetch_arr ay(): supplied argument is not a valid MySQL result resource in w:\home\localho st\www\kasya\db .php on line 9
  • iam_clint
    Recognized Expert Top Contributor
    • Jul 2006
    • 1207

    #2
    Thats saying that $result is empty more then likely your sql query is incorrect.

    Comment

    • Banfa
      Recognized Expert Expert
      • Feb 2006
      • 9067

      #3
      The query

      $query = "SELECT * FROM `user_info` VALUES('user_na me','user_pass' )";

      Is wrong there is no VALUES clause to a select query. I think you mean either

      $query = "SELECT * FROM `user_info`";

      or

      $query = "SELECT user_name,user_ pass FROM `user_info`";

      Comment

      Working...