A select Statement using "AND"
Moderator: General Moderators
- Love_Daddy
- Forum Commoner
- Posts: 61
- Joined: Wed Jul 10, 2002 6:55 am
- Location: South Africa
- Contact:
A select Statement using "AND"
Hi All,
I wrote an SQL statement and it gives me an error.
The statement is like this:
$SQL = "Select * from users where emp_no = $emp_no AND password = '$password' ";
And I get the following error:
Warning: PostgreSQL query failed: ERROR: parser: parse error at or near "AND"
in /var/www/html/Voffice/login.php on line 23
Line 23 =
$results = pg_exec($conn,$SQL);
What could be the problem since I need to use both the username and password to authenticate.
And when I use only the emp_no, is works fine.
I wrote an SQL statement and it gives me an error.
The statement is like this:
$SQL = "Select * from users where emp_no = $emp_no AND password = '$password' ";
And I get the following error:
Warning: PostgreSQL query failed: ERROR: parser: parse error at or near "AND"
in /var/www/html/Voffice/login.php on line 23
Line 23 =
$results = pg_exec($conn,$SQL);
What could be the problem since I need to use both the username and password to authenticate.
And when I use only the emp_no, is works fine.
- Love_Daddy
- Forum Commoner
- Posts: 61
- Joined: Wed Jul 10, 2002 6:55 am
- Location: South Africa
- Contact:
Thanks, But how do I make sure that my username and password doesn't show on the
URL location?
Can anyone show me a basic script of using sessions, for I've tried reading them and I don't
understand.
So Could I get a basic script explaining them from top to bottom please?
And how will I see that if the session registered?
URL location?
Can anyone show me a basic script of using sessions, for I've tried reading them and I don't
understand.
So Could I get a basic script explaining them from top to bottom please?
And how will I see that if the session registered?
Session registered ??? Will that query runs ? You may try as follow
Sachin Junghare
________________________
Post Your Question with full decription !!!!
?>
Code: Select all
$SQL = "SELECT * from users where (emp_no = $emp_no AND password = '$password')";Sachin Junghare
________________________
Post Your Question with full decription !!!!
?>
- Love_Daddy
- Forum Commoner
- Posts: 61
- Joined: Wed Jul 10, 2002 6:55 am
- Location: South Africa
- Contact:
Basic sessions are pretty easy. Just call session_start() at the start of the page and session is available. Now you can save session variable like this:
$_SESSION ["user_pswd"] = $user_pswd;
And it stays in the memory as long as user keeps her/his browser open. So, you can do like this from any given page that the user opens during that session.
print($_SESSION["user_pswd"]); and the contents that originally was in $user_pswd is printed out.
Sometimes users get confused like "How can I tell whos password is saved to $_SESSION["user_pswd"]"? You can't. Period. PHP takes care of that. (Actually I guess that you can if you read the session file from the harddisk... and examine that...) Anyhow 100's of users could be using that same page and same script at the same time, and php would still keep count that variables wouldn't be mixed between users, so don't worry about that.
If you want to delete session variable you can say
unset ($_SESSION["user_pswd"]);
or empty whole session:
unset ($_SESSION);
This was the quick&dirty crash course to sessions.... so if you do something important remember to learn more yourself.
NOTE! You can't save/read session variables before session_start is called. (Unless php.ini has been configured to do so.)
--9902468
$_SESSION ["user_pswd"] = $user_pswd;
And it stays in the memory as long as user keeps her/his browser open. So, you can do like this from any given page that the user opens during that session.
print($_SESSION["user_pswd"]); and the contents that originally was in $user_pswd is printed out.
Sometimes users get confused like "How can I tell whos password is saved to $_SESSION["user_pswd"]"? You can't. Period. PHP takes care of that. (Actually I guess that you can if you read the session file from the harddisk... and examine that...) Anyhow 100's of users could be using that same page and same script at the same time, and php would still keep count that variables wouldn't be mixed between users, so don't worry about that.
If you want to delete session variable you can say
unset ($_SESSION["user_pswd"]);
or empty whole session:
unset ($_SESSION);
This was the quick&dirty crash course to sessions.... so if you do something important remember to learn more yourself.
NOTE! You can't save/read session variables before session_start is called. (Unless php.ini has been configured to do so.)
--9902468
Last edited by 9902468 on Mon Sep 09, 2002 7:46 am, edited 1 time in total.
Code: Select all
<?php $SQL = "SELECT * from users where (emp_no = $emp_no AND password = '$password')"; ?>Code: Select all
<?php $emp_no ?>Code: Select all
<?php '$emp_no' ?>- Love_Daddy
- Forum Commoner
- Posts: 61
- Joined: Wed Jul 10, 2002 6:55 am
- Location: South Africa
- Contact: