FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


what is wrong with this query? Please please help!





imagefree
I have been working on a login system. Here is the file that is included in every page and when user fills in the login form, the form is submitted to itself, and then included file comes in action and does login work.

Here occured a proble, everything was working fine, but suddenly this error started displaying:


Code:
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in D:\xampp\htdocs\FRSH\php\check_login.ini on line 14



here is the code:

Code:
<?php



if(isset($_POST['login']))
{
   if(isset($_POST['username'])  &&  isset($_POST['password']))
   {
      $username=trim($_POST['username']);
      $passeord=$_POST['password'];
      $secure_username = addslashes($username);
      $secure_password=md5($password);
      $user_query = "SELECT username FROM frsh_users WHERE username = '$secure_username'";
      $user_check = mysql_query($user_query,$connection);
      if($user_check)
      {
         if(mysql_num_rows($user_check) == 1 )
         {
            $password_query="SELECT password FROM frsh_users WHERE username = '$secure_username'";
            if($password_check = mysql_query($password_query))
            {
               $result=mysql_fetch_array($password_check);
               if(stripslashes($result['password']) == $secure_password)
               {
                  $login_success=1;
                  $_SESSION['username'] = $username;
                  $_SESSION['password'] = $secure_password;
                  if(isset($_POST['remember']))
                  {
                  setcookie("username", $_SESSION['username'], time()+60*60*24*100, "/");
                  setcookie("password", $_SESSION['password'], time()+60*60*24*100, "/");
                  }
               } else $login_errors[]= "wrong password.";
            }
         }
         else
         {
            $login_errors[]= $username." is wrong username.";
         }
      }
      else   $login_errors[]="Problem occured while checking database for " . $username;
   }
}




?>



Before this when i didnt used $connection variable in the line 14 Query, the following error occured.


Code:
Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in D:\xampp\htdocs\FRSH\php\check_login.ini on line 14

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in D:\xampp\htdocs\FRSH\php\check_login.ini on line 14


I havent set the username ODBC. What is this? please help me.

Thanks
imagefree
here is the connection file. File is placed in a directory /php/ inside my site.


Code:
<?php

//This file keeps PHP variables and their values.

$include_path='includes/';

?>


<?php

$connection=mysql_connect("localhost", "root", "") or die("Cannot Connect to MySQL. Try Later.");
mysql_select_db('frsh') or die("Database Cannot be selected. Try Later.");

?>



This file is too included in each and every main page (register.php, index.php, help.php etc) and so, the connection info passes to the login file pasted in the previous post.


Thanks
sonam
Quote:
$passeord=$_POST['password'];

I think how this is type mistake and potential error. Latter you are using password.

Sonam
imagefree
THanks, but script is still not working, same problem prevails.


Also can you please tell me what is the reason behind the error of ODBC username when i donot use connection variable?

Problem is still there, please help!
sonam
Code:
$connection=mysql_connect("localhost", "root", "")


I think how you need change this with your username and password.

Code:
$connection=mysql_connect("localhost", "imagefree", "yourpassword")


or you can create one new username and password in your CP or DA (this is more secure for me).

Sonam
imagefree
sonam wrote:
Code:
$connection=mysql_connect("localhost", "root", "")


I think how you need change this with your username and password.

Code:
$connection=mysql_connect("localhost", "imagefree", "yourpassword")


or you can create one new username and password in your CP or DA (this is more secure for me).

Sonam



Thanks sonam for your help. Yes its insecure, but i am using it on development computer.
Anyways, the problem is found. Actually i included the file containing the connection info after the file i posted in the original post. So, that unusual and unexpected error was occuring.


Thanks again for the spelling correction. Very Happy
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.